1 // { dg-do run } 2 3 // Contributed by Nathan Sidwell 15 Dec 2003 <nathan@codesourcery.com> 4 // Origin: Tasso Karkanis <Tasso.Karkanis@rogers.com> 5 // PR c++/13387. Clobbered tail padding of base 6 new(__SIZE_TYPE__,void * ptr)7inline void *operator new (__SIZE_TYPE__, void *ptr) 8 { 9 return ptr; 10 } 11 12 struct Base { BaseBase13 Base() : i(0), c(0) {} 14 int i; 15 char c; 16 }; 17 18 struct Sub : Base { SubSub19 Sub () : d(0) {} 20 char d; 21 }; 22 main()23int main() { 24 Sub sub; 25 char base_alias[sizeof (Base)]; 26 Base *base; 27 28 for (unsigned ix = sizeof base_alias; ix--;) 29 base_alias[ix] = 0x55; 30 base = new (&base_alias) Base (); 31 32 static_cast <Base &> (sub) = *base; 33 return sub.d; 34 } 35