http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55171
Bug #: 55171
Summary: incorrect virtual thunk on mingw
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
Created attachment 28593
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28593
test for virtual call on mingw
When a virtual call invoked on an object which uses both virtual and
non-virtual inheritance, the virtual thunk leaves the target function with an
invalid "this" pointer.
Attached test fails with output:
created Derived object at: 0x2c1a50
Derived virtual call at: 0x409800
Assertion failed!
>From gdb:
In the body of the most-derived constructor
(gdb) inf vt this
vtable for 'Derived' @ 0x4097ec (subobject @ 0x2c1a50):
[0]: 0x40188a <Derived::~Derived()>
[1]: 0x40190a <Derived::~Derived()>
[2]: 0x401932 <Derived::foo() const>
vtable for 'VirtBase' @ 0x409808 (subobject @ 0x2c1a58):
[0]: 0x401902 <virtual thunk to Derived::~Derived()>
[1]: 0x40192a <virtual thunk to Derived::~Derived()>
[2]: 0x4019d1 <virtual thunk to Derived::foo() const>
0x004019d1 in virtual thunk to Derived::foo() const () at gccbug.cpp:45
Dump of assembler code for function _ZTv0_n16_NK7Derived3fooEv:
=> 0x004019d1 <+0>: mov 0x4(%esp),%eax
0x004019d5 <+4>: mov (%eax),%eax
0x004019d7 <+6>: add -0x10(%eax),%eax
0x004019da <+9>: mov %eax,0x4(%esp)
0x004019de <+13>: jmp 0x401932 <Derived::foo() const>
After thunk has jumped to target function
Derived::foo (this=0x409800) at gccbug.cpp:41
41 {
(gdb) inf vt this
Cannot access memory at address 0xffffffec