Skip to content
Commit 23cdd943 authored by Hannes Domani's avatar Hannes Domani
Browse files

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: default avatarTom Tromey <tom@tromey.com>
parent e8f6050c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment