This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/1611: c++ new-abi generates bad code with virtual derivation
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/1611: c++ new-abi generates bad code with virtual derivation
- From: snyder at fnal dot gov
- Date: Wed, 10 Jan 2001 21:51:31 -0600
- Reply-To: snyder at fnal dot gov
>Number: 1611
>Category: c++
>Synopsis: c++ new-abi generates bad code with virtual derivation
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Wed Jan 10 20:16:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: scott snyder
>Release: 2.97 20010110 (experimental)
>Organization:
>Environment:
System: Linux karma 2.2.16-22 #1 Tue Aug 22 16:49:06 EDT 2000 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../egcs/configure --prefix=/usr/local/egcs --enable-libstdcxx-v3 --enable-threads=posix --enable-cheaders=c_shadow : (reconfigured)
>Description:
I'm seeing a crash in my code when i try to use new abi, with a
somewhat complicated virtual derivation layout.
It looks like the destructor for a virtual base class is being
called with the wrong offset into the complete object --- members
of the virtual base have garbage values.
>How-To-Repeat:
Here's a test case:
-------------------------------------------------------------------
#include <assert.h>
struct d0_Object
{
d0_Object () : _indptr (12345) {}
virtual ~d0_Object () { assert (_indptr == 12345); }
int _indptr;
};
class M10 : virtual public d0_Object {};
struct M8 : virtual public d0_Object {};
struct M9 : public M8, virtual public M10 {};
int main (int argc, char* argv[])
{
M9 dum;
return 0;
}
-------------------------------------------------------------------
This program should run and exit silently without error.
In the d0_Object virtual base, the constructor initializes
the member field _indptr; the destructor then just checks to be
sure that the member has the same value to which it was
set in the constructor. But when i run it, i see the assertion
firing:
$ g++ -o x x.cc
$ ./x
x: x.cc:7: virtual d0_Object::~d0_Object(): Assertion `_indptr == 12345' failed.
Aborted (core dumped)
I did not see this problem using the old abi.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
With Ben's patch:
2001-01-10 Benjamin Kosnik <bkoz@redhat.com>
* pt.c (check_explicit_specialization): Disable 2000-12-14 change.