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
* [Bug c++/28907] Wrong pointer cast with multiple inheritance
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 ` ssbssa at sourceware dot org
2022-04-02 16:14 ` tromey at sourceware dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: ssbssa at sourceware dot org @ 2022-02-24 18:34 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=28907
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] 5+ messages in thread
* [Bug c++/28907] Wrong pointer cast with multiple inheritance
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
3 siblings, 0 replies; 5+ messages in thread
From: tromey at sourceware dot org @ 2022-04-02 16:14 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=28907
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
Assignee|unassigned at sourceware dot org |tromey at sourceware dot org
--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
Sending a patch.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/28907] Wrong pointer cast with multiple inheritance
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
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-18 15:45 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=28907
--- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2390419d1cb72882110538e01e5586372df19657
commit 2390419d1cb72882110538e01e5586372df19657
Author: Tom Tromey <tom@tromey.com>
Date: Sat Apr 2 09:54:40 2022 -0600
Fix C++ cast of derived class to base class
PR c++/28907 points out that casting from a derived class to a base
class fails in some situations. The problem turned out to be a
missing use of value_embedded_offset. One peculiarity here is that,
if you managed to construct a pointer-to-derived with an embedded
offset of 0, the cast would work -- for example, one of the two new
tests here passes without the patch.
This embedded offset stuff is an endless source of bugs. I wonder if
it's possible to get rid of it somehow.
Regression tested on x86-64 Fedora 34.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28907
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/28907] Wrong pointer cast with multiple inheritance
2022-02-18 16:49 [Bug c++/28907] New: Wrong pointer cast with multiple inheritance simark at simark dot ca
` (2 preceding siblings ...)
2022-04-18 15:45 ` cvs-commit at gcc dot gnu.org
@ 2022-04-18 15:46 ` tromey at sourceware dot org
3 siblings, 0 replies; 5+ messages in thread
From: tromey at sourceware dot org @ 2022-04-18 15:46 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=28907
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |13.1
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
Fixed.
--
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).