From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C22E7384243B; Fri, 28 Aug 2020 20:06:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C22E7384243B From: "palves at redhat dot com" To: gdb-prs@sourceware.org Subject: [Bug c++/26550] New: Object of class with virtual base classes printed incorrectly (gdb.cp/ambiguous.exp) Date: Fri, 28 Aug 2020 20:06:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: palves at redhat 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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: Fri, 28 Aug 2020 20:06:49 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26550 Bug ID: 26550 Summary: Object of class with virtual base classes printed incorrectly (gdb.cp/ambiguous.exp) Product: gdb Version: unknown Status: NEW Severity: normal Priority: P2 Component: c++ Assignee: unassigned at sourceware dot org Reporter: palves at redhat dot com Target Milestone: --- The gdb.cp/ambiguous.exp testcase ( as soon as these changes land in master: https://sourceware.org/pipermail/gdb-patches/2020-August/171526.html ) runs into a GDB bug where GDB prints a value with virtual base classes incorrectly. The class in question inherits from A1 directly and also inherits from two other distinct base classes that inherit virtually from A1 in turn: class A1 { public: int x; int y; }; class LV : public virtual A1 { public: int z; }; class KV : public virtual A1 { public: int i; }; class JVA1 : public KV, public LV, public A1 { public: int jva1; }; and then is initialized like this: JVA1 jva1; jva1.KV::x =3D 1; jva1.KV::y =3D 2; jva1.LV::x =3D 3; jva1.LV::y =3D 4; jva1.z =3D 5; jva1.i =3D 6; jva1.jva1 =3D 7; The testcase shows: print jva1.KV::x $51 =3D 1431665544 (gdb) FAIL: gdb.cp/ambiguous.exp: all fields: print jva1.KV::x print jva1.KV::y $52 =3D 21845 (gdb) FAIL: gdb.cp/ambiguous.exp: all fields: print jva1.KV::y (gdb) print /x (KV)jva1 $4 =3D { =3D , _vptr.KV =3D 0x555555557b88 , i =3D 0x457} (gdb) print /x (A1)(KV)jva1 Cannot access memory at address 0x0 And with the following we see how GDB is clearly confusing the offset of _vptr.KV with the offset of A1: (gdb) print /x jva1 $1 =3D { =3D { =3D {x =3D 0x2, y =3D 0x16}, _vptr.KV =3D 0x5555555= 57b88 , i =3D 0x457}, ......} ^^^^^^^^^^^^^^ (gdb) print /x jva1.KV::x $2 =3D 0x55557b88 ^^^^^^^^^^ (gdb) print /x jva1.KV::y $3 =3D 0x5555 ^^^^^^ --=20 You are receiving this mail because: You are on the CC list for the bug.=