// { dg-do run }
|
// { dg-do run }
|
// Copyright (C) 2000 Free Software Foundation, Inc.
|
// Copyright (C) 2000 Free Software Foundation, Inc.
|
// Contributed by Nathan Sidwell 19 Jan 2001
|
// Contributed by Nathan Sidwell 19 Jan 2001
|
|
|
// Bug 1701. building a vbase path was not using the shortest number of
|
// Bug 1701. building a vbase path was not using the shortest number of
|
// vbases. Normally that's just a pessimization, unfortunately during
|
// vbases. Normally that's just a pessimization, unfortunately during
|
// constructoring it leads to uninitialized reads.
|
// constructoring it leads to uninitialized reads.
|
|
|
extern "C" int printf (...);
|
extern "C" int printf (...);
|
|
|
int fail = 0;
|
int fail = 0;
|
|
|
/*{{{ struct Base*/
|
/*{{{ struct Base*/
|
struct Base
|
struct Base
|
{
|
{
|
unsigned m;
|
unsigned m;
|
static Base *addr;
|
static Base *addr;
|
|
|
Base ();
|
Base ();
|
virtual ~Base ();
|
virtual ~Base ();
|
};
|
};
|
/*}}}*/
|
/*}}}*/
|
Base *Base::addr;
|
Base *Base::addr;
|
/*{{{ Base::Base ()*/
|
/*{{{ Base::Base ()*/
|
Base::Base ()
|
Base::Base ()
|
{
|
{
|
printf ("Base (%u) ctor %x\n", sizeof (Base), this);
|
printf ("Base (%u) ctor %x\n", sizeof (Base), this);
|
if (fail) ;
|
if (fail) ;
|
else if (addr)
|
else if (addr)
|
fail = 1;
|
fail = 1;
|
else
|
else
|
addr = this;
|
addr = this;
|
}
|
}
|
/*}}}*/
|
/*}}}*/
|
/*{{{ Base::~Base ()*/
|
/*{{{ Base::~Base ()*/
|
Base::~Base ()
|
Base::~Base ()
|
{
|
{
|
printf ("Base dtor %x\n", this);
|
printf ("Base dtor %x\n", this);
|
if (fail)
|
if (fail)
|
;
|
;
|
else if (this != addr)
|
else if (this != addr)
|
fail = 2;
|
fail = 2;
|
else
|
else
|
addr = 0;
|
addr = 0;
|
}
|
}
|
/*}}}*/
|
/*}}}*/
|
|
|
/*{{{ struct M10 : virtual Base*/
|
/*{{{ struct M10 : virtual Base*/
|
struct M10 : virtual Base
|
struct M10 : virtual Base
|
{
|
{
|
int m;
|
int m;
|
static M10 *addr;
|
static M10 *addr;
|
|
|
M10 ();
|
M10 ();
|
virtual ~M10 ();
|
virtual ~M10 ();
|
};
|
};
|
/*}}}*/
|
/*}}}*/
|
M10 *M10::addr;
|
M10 *M10::addr;
|
/*{{{ M10::M10 ()*/
|
/*{{{ M10::M10 ()*/
|
M10::M10 ()
|
M10::M10 ()
|
{
|
{
|
printf ("M10 (%u) ctor %x\n", sizeof (M10), this);
|
printf ("M10 (%u) ctor %x\n", sizeof (M10), this);
|
if (fail) ;
|
if (fail) ;
|
else if (addr)
|
else if (addr)
|
fail = 3;
|
fail = 3;
|
else
|
else
|
addr = this;
|
addr = this;
|
}
|
}
|
/*}}}*/
|
/*}}}*/
|
/*{{{ M10::~M10 ()*/
|
/*{{{ M10::~M10 ()*/
|
M10::~M10 ()
|
M10::~M10 ()
|
{
|
{
|
printf ("M10 dtor %x\n", this);
|
printf ("M10 dtor %x\n", this);
|
if (fail)
|
if (fail)
|
;
|
;
|
else if (this != addr)
|
else if (this != addr)
|
fail = 4;
|
fail = 4;
|
else
|
else
|
addr = 0;
|
addr = 0;
|
}
|
}
|
/*}}}*/
|
/*}}}*/
|
|
|
/*{{{ struct M4 : virtual Base, virtual M10*/
|
/*{{{ struct M4 : virtual Base, virtual M10*/
|
struct M4 : virtual Base, virtual M10
|
struct M4 : virtual Base, virtual M10
|
{
|
{
|
int m;
|
int m;
|
static M4 *addr;
|
static M4 *addr;
|
|
|
M4 ();
|
M4 ();
|
virtual ~M4 ();
|
virtual ~M4 ();
|
};
|
};
|
/*}}}*/
|
/*}}}*/
|
M4 *M4::addr;
|
M4 *M4::addr;
|
/*{{{ M4::M4 ()*/
|
/*{{{ M4::M4 ()*/
|
M4::M4 ()
|
M4::M4 ()
|
{
|
{
|
printf ("M4 (%u) ctor %x\n", sizeof (M4), this);
|
printf ("M4 (%u) ctor %x\n", sizeof (M4), this);
|
if (fail) ;
|
if (fail) ;
|
else if (addr)
|
else if (addr)
|
fail = 5;
|
fail = 5;
|
else
|
else
|
addr = this;
|
addr = this;
|
}
|
}
|
/*}}}*/
|
/*}}}*/
|
/*{{{ M4::~M4 ()*/
|
/*{{{ M4::~M4 ()*/
|
M4::~M4 ()
|
M4::~M4 ()
|
{
|
{
|
printf ("M4 dtor %x\n", this);
|
printf ("M4 dtor %x\n", this);
|
if (fail)
|
if (fail)
|
;
|
;
|
else if (this != addr)
|
else if (this != addr)
|
fail = 6;
|
fail = 6;
|
else
|
else
|
addr = 0;
|
addr = 0;
|
}
|
}
|
/*}}}*/
|
/*}}}*/
|
|
|
/*{{{ struct M5 : M4*/
|
/*{{{ struct M5 : M4*/
|
struct M5 : M4
|
struct M5 : M4
|
{
|
{
|
int m;
|
int m;
|
static M5 *addr;
|
static M5 *addr;
|
|
|
M5 ();
|
M5 ();
|
virtual ~M5 ();
|
virtual ~M5 ();
|
};
|
};
|
/*}}}*/
|
/*}}}*/
|
M5 *M5::addr;
|
M5 *M5::addr;
|
/*{{{ M5::M5 ()*/
|
/*{{{ M5::M5 ()*/
|
M5::M5 ()
|
M5::M5 ()
|
{
|
{
|
printf ("M5 (%u) ctor %x\n", sizeof (M5), this);
|
printf ("M5 (%u) ctor %x\n", sizeof (M5), this);
|
if (fail) ;
|
if (fail) ;
|
else if (addr)
|
else if (addr)
|
fail = 7;
|
fail = 7;
|
else
|
else
|
addr = this;
|
addr = this;
|
}
|
}
|
/*}}}*/
|
/*}}}*/
|
/*{{{ M5::~M5 ()*/
|
/*{{{ M5::~M5 ()*/
|
M5::~M5 ()
|
M5::~M5 ()
|
{
|
{
|
printf ("M5 dtor %x\n", this);
|
printf ("M5 dtor %x\n", this);
|
if (fail)
|
if (fail)
|
;
|
;
|
else if (this != addr)
|
else if (this != addr)
|
fail = 8;
|
fail = 8;
|
else
|
else
|
addr = 0;
|
addr = 0;
|
}
|
}
|
/*}}}*/
|
/*}}}*/
|
|
|
/*{{{ struct M9 : M5, virtual M10*/
|
/*{{{ struct M9 : M5, virtual M10*/
|
struct M9 : M5, virtual M10
|
struct M9 : M5, virtual M10
|
{
|
{
|
int m;
|
int m;
|
static M9 *addr;
|
static M9 *addr;
|
|
|
M9 ();
|
M9 ();
|
virtual ~M9 ();
|
virtual ~M9 ();
|
};
|
};
|
/*}}}*/
|
/*}}}*/
|
M9 *M9::addr;
|
M9 *M9::addr;
|
/*{{{ M9::M9 ()*/
|
/*{{{ M9::M9 ()*/
|
M9::M9 ()
|
M9::M9 ()
|
{
|
{
|
printf ("M9 (%u), ctor %x\n", sizeof (M9), this);
|
printf ("M9 (%u), ctor %x\n", sizeof (M9), this);
|
if (fail) ;
|
if (fail) ;
|
else if (addr)
|
else if (addr)
|
fail = 9;
|
fail = 9;
|
else
|
else
|
addr = this;
|
addr = this;
|
}
|
}
|
/*}}}*/
|
/*}}}*/
|
/*{{{ M9::~M9 ()*/
|
/*{{{ M9::~M9 ()*/
|
M9::~M9 ()
|
M9::~M9 ()
|
{
|
{
|
printf ("M9 dtor %x\n", this);
|
printf ("M9 dtor %x\n", this);
|
if (fail)
|
if (fail)
|
;
|
;
|
else if (this != addr)
|
else if (this != addr)
|
fail = 10;
|
fail = 10;
|
else
|
else
|
addr = 0;
|
addr = 0;
|
}
|
}
|
/*}}}*/
|
/*}}}*/
|
|
|
int main ()
|
int main ()
|
{
|
{
|
M9 *m9;
|
M9 *m9;
|
Base *r;
|
Base *r;
|
|
|
m9 = new M9 ();
|
m9 = new M9 ();
|
r = m9;
|
r = m9;
|
if (fail)
|
if (fail)
|
return fail;
|
return fail;
|
void *top = dynamic_cast (r);
|
void *top = dynamic_cast (r);
|
if (top != m9)
|
if (top != m9)
|
return 20;
|
return 20;
|
r->~Base ();
|
r->~Base ();
|
|
|
return fail;
|
return fail;
|
}
|
}
|
|
|