public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/28907] New: Wrong pointer cast with multiple inheritance
@ 2022-02-18 16:49 simark at simark dot ca
  2022-02-24 18:34 ` [Bug c++/28907] " ssbssa at sourceware dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: simark at simark dot ca @ 2022-02-18 16:49 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=28907

            Bug ID: 28907
           Summary: Wrong pointer cast with multiple inheritance
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
          Assignee: unassigned at sourceware dot org
          Reporter: simark at simark dot ca
  Target Milestone: ---

$ cat test.cpp                                                       
struct Base1 {
  int b1 = 0x1111;
};

struct Base2 {
  int b2 = 0x2222;
};

struct Derived : public Base1, Base2 {
  int d = 0x3333;
};

int main() {
  Derived d;
  return 0;
}
$ g++ test.cpp -g3 -O0                                               
$ DEBUGINFOD_URLS= ./gdb -nx -q --data-directory=data-directory a.out -ex "b
15" -ex r
Reading symbols from a.out...
Breakpoint 1 at 0x1165: file test.cpp, line 15.
Starting program: /home/simark/build/binutils-gdb/gdb/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/../lib/libthread_db.so.1".

Breakpoint 1, main () at test.cpp:15
15        return 0;
(gdb) p &d
$1 = (Derived *) 0x7fffffffdcfc
(gdb) p (Base2 *) &d
$2 = (Base2 *) 0x7fffffffdd00
(gdb) p (Derived *) (Base2 *) &d
$3 = (Derived *) 0x7fffffffdcf8


Pretty sure that $1 and $3 should be equal.

Might be related to https://sourceware.org/bugzilla/show_bug.cgi?id=20285.  Not
quite the same, but it might be the same root cause.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-18 15:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-18 16:49 [Bug c++/28907] New: Wrong pointer cast with multiple inheritance simark at simark dot ca
2022-02-24 18:34 ` [Bug c++/28907] " ssbssa at sourceware dot org
2022-04-02 16:14 ` tromey at sourceware dot org
2022-04-18 15:45 ` cvs-commit at gcc dot gnu.org
2022-04-18 15:46 ` tromey at sourceware dot 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).