public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug tui/31399] New: Build fails on macOS: error: cannot cast 'tui_win_info *' to 'tui_cmd_window *' via virtual base 'tui_win_info'
@ 2024-02-19 3:08 spam_hole at shaw dot ca
2024-02-19 14:34 ` [Bug tui/31399] " ssbssa at sourceware dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: spam_hole at shaw dot ca @ 2024-02-19 3:08 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31399
Bug ID: 31399
Summary: Build fails on macOS: error: cannot cast 'tui_win_info
*' to 'tui_cmd_window *' via virtual base
'tui_win_info'
Product: gdb
Version: HEAD
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: tui
Assignee: unassigned at sourceware dot org
Reporter: spam_hole at shaw dot ca
Target Milestone: ---
Building binutils+gdb from binutils-2.42 source fails with the following error:
======== 8< ========
In file included from ../../gdb/tui/tui-command.c:24:
In file included from ../../gdb/tui/tui-data.h:28:
../../gdb/../gdbsupport/gdb-checked-static-cast.h:63:14: error: cannot cast
'tui_win_info *' to 'tui_cmd_window *' via virtual base 'tui_win_info'
T result = static_cast<T> (v);
^~~~~~~~~~~~~~~~~~
../../gdb/tui/tui-command.c:65:15: note: in instantiation of function template
specialization 'gdb::checked_static_cast<tui_cmd_window *, tui_win_info>'
requested here
WINDOW *w = TUI_CMD_WIN->handle.get ();
^
../../gdb/tui/tui-data.h:299:9: note: expanded from macro 'TUI_CMD_WIN'
(gdb::checked_static_cast<tui_cmd_window *> (tui_win_list[CMD_WIN]))
^
1 error generated.
======== 8< ========
Build fails with Apple clang version 15.0.0 (clang-1500.1.0.2.5) on macOS
13.6.1 (22G313).
This is a regression apparently originating in commit
85a427b26c5cae6af6ed0b4358d44a77b5a3b2c0
(https://git.libre-soc.org/?p=binutils-gdb.git;a=commit;h=85a427b26c5cae6af6ed0b4358d44a77b5a3b2c0).
I believe dynamic_cast is needed instead of static_cast.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tui/31399] Build fails on macOS: error: cannot cast 'tui_win_info *' to 'tui_cmd_window *' via virtual base 'tui_win_info'
2024-02-19 3:08 [Bug tui/31399] New: Build fails on macOS: error: cannot cast 'tui_win_info *' to 'tui_cmd_window *' via virtual base 'tui_win_info' spam_hole at shaw dot ca
@ 2024-02-19 14:34 ` ssbssa at sourceware dot org
2024-02-22 15:06 ` [Bug build/31399] " vries at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ssbssa at sourceware dot org @ 2024-02-19 14:34 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31399
Hannes Domani <ssbssa at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ssbssa at sourceware dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug build/31399] Build fails on macOS: error: cannot cast 'tui_win_info *' to 'tui_cmd_window *' via virtual base 'tui_win_info'
2024-02-19 3:08 [Bug tui/31399] New: Build fails on macOS: error: cannot cast 'tui_win_info *' to 'tui_cmd_window *' via virtual base 'tui_win_info' spam_hole at shaw dot ca
2024-02-19 14:34 ` [Bug tui/31399] " ssbssa at sourceware dot org
@ 2024-02-22 15:06 ` vries at gcc dot gnu.org
2024-02-22 16:19 ` vries at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2024-02-22 15:06 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31399
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vries at gcc dot gnu.org
Component|tui |build
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug build/31399] Build fails on macOS: error: cannot cast 'tui_win_info *' to 'tui_cmd_window *' via virtual base 'tui_win_info'
2024-02-19 3:08 [Bug tui/31399] New: Build fails on macOS: error: cannot cast 'tui_win_info *' to 'tui_cmd_window *' via virtual base 'tui_win_info' spam_hole at shaw dot ca
2024-02-19 14:34 ` [Bug tui/31399] " ssbssa at sourceware dot org
2024-02-22 15:06 ` [Bug build/31399] " vries at gcc dot gnu.org
@ 2024-02-22 16:19 ` vries at gcc dot gnu.org
2024-02-24 10:00 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2024-02-22 16:19 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31399
--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
https://sourceware.org/pipermail/gdb-patches/2024-February/206767.html
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug build/31399] Build fails on macOS: error: cannot cast 'tui_win_info *' to 'tui_cmd_window *' via virtual base 'tui_win_info'
2024-02-19 3:08 [Bug tui/31399] New: Build fails on macOS: error: cannot cast 'tui_win_info *' to 'tui_cmd_window *' via virtual base 'tui_win_info' spam_hole at shaw dot ca
` (2 preceding siblings ...)
2024-02-22 16:19 ` vries at gcc dot gnu.org
@ 2024-02-24 10:00 ` cvs-commit at gcc dot gnu.org
2024-02-24 10:01 ` vries at gcc dot gnu.org
2024-03-19 14:57 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-24 10:00 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31399
--- Comment #2 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:
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
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug build/31399] Build fails on macOS: error: cannot cast 'tui_win_info *' to 'tui_cmd_window *' via virtual base 'tui_win_info'
2024-02-19 3:08 [Bug tui/31399] New: Build fails on macOS: error: cannot cast 'tui_win_info *' to 'tui_cmd_window *' via virtual base 'tui_win_info' spam_hole at shaw dot ca
` (3 preceding siblings ...)
2024-02-24 10:00 ` cvs-commit at gcc dot gnu.org
@ 2024-02-24 10:01 ` vries at gcc dot gnu.org
2024-03-19 14:57 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2024-02-24 10:01 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31399
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Target Milestone|--- |15.1
Resolution|--- |FIXED
--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
Fixed.
Thanks for reporting this.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug build/31399] Build fails on macOS: error: cannot cast 'tui_win_info *' to 'tui_cmd_window *' via virtual base 'tui_win_info'
2024-02-19 3:08 [Bug tui/31399] New: Build fails on macOS: error: cannot cast 'tui_win_info *' to 'tui_cmd_window *' via virtual base 'tui_win_info' spam_hole at shaw dot ca
` (4 preceding siblings ...)
2024-02-24 10:01 ` vries at gcc dot gnu.org
@ 2024-03-19 14:57 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-19 14:57 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31399
--- Comment #4 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Burgess <aburgess@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7d18eb9983b00455fd2f3100d4de2772c3f656ad
commit 7d18eb9983b00455fd2f3100d4de2772c3f656ad
Author: Andrew Burgess <aburgess@redhat.com>
Date: Wed Mar 6 17:28:48 2024 +0000
gdb: use static_cast in gdb::checked_static_cast
This commit:
commit 6fe4779ac4b1874c995345e3eabd89cb1a05fbdf
Date: Sat Feb 24 11:00:20 2024 +0100
[gdb/build] Fix static cast of virtual base
addressed an issue where GDB would not compile in production mode due
to a use of gdb::checked_static_cast. The problem was that we were
asking GDB to cast from a virtual base class to a sub-class, this
works fine when using dynamic_cast, but does not work with
static_cast.
The gdb::checked_static_cast actually uses dynamic_cast under the hood
in development mode in order to ensure that the cast is valid, while
in a production build we use static_cast as this is more efficient.
What this meant however, was that when gdb::checked_static_cast was
used to cast from a virtual base class, the dynamic_cast of a
non-production build worked fine, while the production build's
static_cast caused a build failure.
However, the gdb::checked_static_cast function already contains some
static_assert calls that are intended to catch any issues with invalid
type casting, the goal of these asserts was to prevent issues like
this: the build only failing in production mode. Clearly the current
asserts are not enough.
I don't think there is a std::is_virtual_base type trait check, so
what I propose instead is that in non-production mode we also make use
of static_cast. This will ensure that any errors that crop up in
production mode should also be revealed in non-production mode, and
should catch issues like this in the future.
There should be no user visible changes after this commit.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31399
Co-Authored-By: Simon Marchi <simon.marchi@polymtl.ca>
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-03-19 14:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19 3:08 [Bug tui/31399] New: Build fails on macOS: error: cannot cast 'tui_win_info *' to 'tui_cmd_window *' via virtual base 'tui_win_info' spam_hole at shaw dot ca
2024-02-19 14:34 ` [Bug tui/31399] " ssbssa at sourceware dot org
2024-02-22 15:06 ` [Bug build/31399] " vries at gcc dot gnu.org
2024-02-22 16:19 ` vries at gcc dot gnu.org
2024-02-24 10:00 ` cvs-commit at gcc dot gnu.org
2024-02-24 10:01 ` vries at gcc dot gnu.org
2024-03-19 14:57 ` cvs-commit at gcc dot gnu.org
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).