From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH] [gdb/build] Fix static cast of virtual base
Date: Thu, 22 Feb 2024 17:18:04 +0100 [thread overview]
Message-ID: <20240222161804.1134-1-tdevries@suse.de> (raw)
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>
PR build/31399
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31399
---
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. */
base-commit: 94aadbf48f608a2d65d4a0ba259f43dada16fda4
--
2.35.3
next reply other threads:[~2024-02-22 16:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-22 16:18 Tom de Vries [this message]
2024-02-23 13:56 ` Tom Tromey
2024-03-06 17:39 ` Andrew Burgess
2024-03-06 18:27 ` Simon Marchi
2024-03-08 16:18 ` Tom Tromey
2024-03-11 10:25 ` Andrew Burgess
2024-03-11 16:22 ` Simon Marchi
2024-03-19 14:58 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240222161804.1134-1-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).