From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 4D207385842A; Sat, 24 Feb 2024 10:00:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D207385842A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1708768824; bh=B7U4WWr+6BOLJsmESL4A8tDOtiZslxS15QiYuixHNJg=; h=From:To:Subject:Date:From; b=Dlu81TIBy1b1a3jwqrv0H0pC75nSTMi0WKwKu/Lbl+0vaLBbvWtGdKB+lzKu3Y5A6 MBlv0wTObvKdOLX9lR0USsCSlktMKmXrMYKWzQxUJwFzjsSvsJyrmaqSbJbTAjSh2A bZXL5aebe6Qlfzo2d1TycaOJnmuQW3j77m1xJUmo= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/build] Fix static cast of virtual base X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 086c8f406d82ce171d5867eed93f1308e07252c5 X-Git-Newrev: 6fe4779ac4b1874c995345e3eabd89cb1a05fbdf Message-Id: <20240224100024.4D207385842A@sourceware.org> Date: Sat, 24 Feb 2024 10:00:24 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D6fe4779ac4b1= 874c995345e3eabd89cb1a05fbdf commit 6fe4779ac4b1874c995345e3eabd89cb1a05fbdf Author: Tom de Vries Date: Sat Feb 24 11:00:20 2024 +0100 [gdb/build] Fix static cast of virtual base =20 With this change in bfd/development.sh: ... -development=3Dtrue +development=3Dfalse ... 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 \ =E2=80=98T gdb::checked_static_cast(V*) [with T =3D tui_cmd_window*; = V =3D tui_win_info]=E2=80=99: tui-command.c:65:15: required from here gdb-checked-static-cast.h:63:14: error: cannot convert from pointer to = base \ class =E2=80=98tui_win_info=E2=80=99 to pointer to derived class =E2= =80=98tui_cmd_window=E2=80=99 because \ the base is virtual T result =3D static_cast (v); ^~~~~~~~~~~~~~~~~~ ... =20 Fix this by using dynamic_cast instead of gdb::checked_static_cast in TUI_CMD_WIN and TUI_STATUS_WIN. =20 Tested on x86_64-linux, with development set to false. =20 Reported-By: Robert Xiao Reported-By: Simon Marchi Approved-By: Tom Tromey =20 PR build/31399 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31399 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_WIND= OWS]; #define TUI_DATA_WIN \ (gdb::checked_static_cast (tui_win_list[DATA_WIN])) #define TUI_CMD_WIN \ - (gdb::checked_static_cast (tui_win_list[CMD_WIN])) + (dynamic_cast (tui_win_list[CMD_WIN])) #define TUI_STATUS_WIN \ - (gdb::checked_static_cast (tui_win_list[STATUS_WIN]= )) + (dynamic_cast (tui_win_list[STATUS_WIN])) =20 /* All the windows that are currently instantiated, in layout order. */