From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 08635385800C; Thu, 4 Nov 2021 17:36:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08635385800C From: "jwakely.gcc at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug gdb/28480] pretty printing getting confused Date: Thu, 04 Nov 2021 17:36:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jwakely.gcc at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: see_also Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2021 17:36:32 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28480 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=3D103086 --- Comment #11 from Jonathan Wakely --- I've created https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103086 for this= , with a more detailed explanation. I think GDB's new behaviour is probably better, and the libstdc++ printers should be fixed. However, Bruno did suggest that when tuple_member['_M_head_impl'] is ambigu= ous it should give an error, not silently return either the first or last match= ing member. For example, in this code: struct X { int i =3D 0x1; }; struct Y { char i =3D 'Y'; }; struct Z : X, Y { }; int main() { Z z; return 0; } GDB 10 will happily print z.i $ gdb -ex start -ex n -ex "py print(gdb.parse_and_eval('z')['i'])" a.out GNU gdb (GDB) Fedora 10.2-3.fc34 Copyright (C) 2021 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-redhat-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from a.out... Temporary breakpoint 1 at 0x40110a: file ambig.cc, line 15. Starting program: /tmp/a.out=20 Temporary breakpoint 1, main () at ambig.cc:15 15 Z z; 16 return 0; 89 'Y' But GDB 12 gives an error: $ ~/gcc/gdb/11/bin/gdb -ex start -ex n -ex "py print(gdb.parse_and_eval('z')['i'])" a.out GNU gdb (GDB) 12.0.50.20211020-git Copyright (C) 2021 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from a.out... Temporary breakpoint 1 at 0x40110a: file ambig.cc, line 15. Starting program: /tmp/a.out=20 Temporary breakpoint 1, main () at ambig.cc:15 15 Z z; 16 return 0; Traceback (most recent call last): File "", line 1, in gdb.error: Request for member 'i' is ambiguous in type 'Z'. Candidates are: 'int X::i' (Z -> X) 'char Y::i' (Z -> Y) Error while executing Python code. I wonder why there wasn't an error for tuple_member['_M_head_impl'] in the libstdc++ printer. --=20 You are receiving this mail because: You are on the CC list for the bug.=