Summary: | 'reinterpret_cast' in gdb seems to be doing a 'static_cast'. | ||
---|---|---|---|
Product: | gdb | Reporter: | cs120hcc |
Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | ssbssa, tromey |
Priority: | P2 | ||
Version: | HEAD | ||
Target Milestone: | 15.1 | ||
Host: | Target: | ||
Build: | Last reconfirmed: | ||
Attachments: | Sample Code and Repro Transcript |
Description
cs120hcc
2015-08-21 21:27:27 UTC
The master branch has been updated by Hannes Domani <ssbssa@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=23cdd9431ad424b092c65419d47ef4601168a1c9 commit 23cdd9431ad424b092c65419d47ef4601168a1c9 Author: Hannes Domani <ssbssa@yahoo.de> Date: Wed Mar 20 18:02:06 2024 +0100 Fix reinterpret_cast for classes with multiple inheritance Currently a reinterpret_cast may change the pointer value if multiple inheritance is involved: ``` (gdb) p r $1 = (Right *) 0x22f75c (gdb) p reinterpret_cast<LeftRight*>(r) $2 = (LeftRight *) 0x22f758 ``` It's because value_cast is called in this case, which automatically does up- and downcasting. Fixed by simply using the target pointer type in a copy of the original value: ``` (gdb) p r $1 = (Right *) 0x3bf87c (gdb) p reinterpret_cast<LeftRight*>(r) $2 = (LeftRight *) 0x3bf87c ``` Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=18861 Approved-By: Tom Tromey <tom@tromey.com> Fixed. |