1 // { dg-do run } 2 // Origin: Mark Mitchell <mark@codesourcery.com> 3 4 extern "C" void abort (); 5 6 int j; 7 8 struct S { 9 static S* s[5]; 10 SS11 S () { s[j++] = this; } SS12 S (const S&) { s[j++] = this; } ~SS13 ~S () { 14 for (int k = 0; k < j; ++k) 15 if (s[k] == this) 16 return; 17 abort (); 18 } 19 }; 20 21 S* S::s[5]; 22 23 struct T { 24 int i; 25 S s; 26 }; 27 28 T t; 29 f()30T f () { 31 return t; 32 } 33 g(S)34void g (S) { 35 } 36 main()37int main () 38 { 39 g (f ().s); 40 } 41 42