This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/1701: new-abi bug: bad code generated with complex virtual derivation



>Number:         1701
>Category:       c++
>Synopsis:       new-abi bug: bad code generated with complex virtual derivation
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 18 22:56:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     scott snyder
>Release:        2.97 20010118 (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-threads=posix --enable-cheaders=c_shadow : (reconfigured) 
>Description:

The test below creates a single object, with a complicated inheritance
graph involving virtual derivation, and then deletes it.  For the
lowest-level virtual base (d0om_Registerable), i dump out the address
with which the constructor and destructor are called --- and they are
different.  The program then crashes with a segmentation violation.

The code from which this test case was distilled worked ok with the old ABI.

>How-To-Repeat:

---------------------------------------------------------------------
extern "C" int printf (...);

class d0om_Registerable
{
public:
  d0om_Registerable () { printf ("ctor %x\n", this); }
  virtual ~d0om_Registerable () { printf ("dtor %x\n", this); }
  unsigned _registered_mask;
};



struct M10
  : virtual public d0om_Registerable
{
};


struct M4
  : virtual public d0om_Registerable, virtual public M10
{
};


struct M5
  : public M4
{
  int m5a;
};


struct M9
  : public M5, virtual public M10
{
  int m9a;
};


int main ()
{
  d0om_Registerable* r = new M9 ();
  delete r;

  return 0;
}
---------------------------------------------------------------------

$ g++ -o x x.cc
$ ./x
ctor 8051664
dtor 805165c
Segmentation fault (core dumped)
$


>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]