public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb/build] Fix static cast of virtual base
@ 2024-02-24 10:00 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2024-02-24 10:00 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6fe4779ac4b1874c995345e3eabd89cb1a05fbdf

commit 6fe4779ac4b1874c995345e3eabd89cb1a05fbdf
Author: Tom de Vries <tdevries@suse.de>
Date:   Sat Feb 24 11:00:20 2024 +0100

    [gdb/build] Fix static cast of virtual base
    
    With this change in bfd/development.sh:
    ...
    -development=true
    +development=false
    ...
    we run into:
    ...
    In file included from tui-data.h:28:0,
                     from tui-command.c:24:
    gdb-checked-static-cast.h: In instantiation of \
      ‘T gdb::checked_static_cast(V*) [with T = tui_cmd_window*; V = tui_win_info]’:
    tui-command.c:65:15:   required from here
    gdb-checked-static-cast.h:63:14: error: cannot convert from pointer to base \
      class ‘tui_win_info’ to pointer to derived class ‘tui_cmd_window’ because \
      the base is virtual
       T result = static_cast<T> (v);
                  ^~~~~~~~~~~~~~~~~~
    ...
    
    Fix this by using dynamic_cast instead of gdb::checked_static_cast in
    TUI_CMD_WIN and TUI_STATUS_WIN.
    
    Tested on x86_64-linux, with development set to false.
    
    Reported-By: Robert Xiao <spam_hole@shaw.ca>
    Reported-By: Simon Marchi <simark@simark.ca>
    Approved-By: Tom Tromey <tom@tromey.com>
    
    PR build/31399
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31399

Diff:
---
 gdb/tui/tui-data.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 1714f5ae455..90ab01f79af 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -296,9 +296,9 @@ extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
 #define TUI_DATA_WIN \
   (gdb::checked_static_cast<tui_data_window *> (tui_win_list[DATA_WIN]))
 #define TUI_CMD_WIN \
-  (gdb::checked_static_cast<tui_cmd_window *> (tui_win_list[CMD_WIN]))
+  (dynamic_cast<tui_cmd_window *> (tui_win_list[CMD_WIN]))
 #define TUI_STATUS_WIN \
-  (gdb::checked_static_cast<tui_status_window *> (tui_win_list[STATUS_WIN]))
+  (dynamic_cast<tui_status_window *> (tui_win_list[STATUS_WIN]))
 
 /* All the windows that are currently instantiated, in layout
    order.  */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-24 10:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-24 10:00 [binutils-gdb] [gdb/build] Fix static cast of virtual base Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).