From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6472 invoked by alias); 1 Nov 2012 21:11:59 -0000 Received: (qmail 6404 invoked by uid 48); 1 Nov 2012 21:11:40 -0000 From: "mitza at ociweb dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55171] New: incorrect virtual thunk on mingw Date: Thu, 01 Nov 2012 21:11:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mitza at ociweb dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-11/txt/msg00077.txt.bz2 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: unassigned@gcc.gnu.org ReportedBy: mitza@ociweb.com 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 [1]: 0x40190a [2]: 0x401932 vtable for 'VirtBase' @ 0x409808 (subobject @ 0x2c1a58): [0]: 0x401902 [1]: 0x40192a [2]: 0x4019d1 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 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