1 // { dg-do run } 2 3 // Copyright (C) 2002 Free Software Foundation, Inc. 4 // Contributed by Nathan Sidwell 12 Oct 2002 <nathan (at) codesourcery.com> 5 6 // From WindRiver SPR 80797 7 // We were inadvertently SAVE_EXPRing volatile arrays during delete[] 8 9 struct A 10 { 11 A *ptr; 12 static int ok; 13 14 A () {ptr = this;} 15 ~A () {ok = ptr == this;} 16 }; 17 int A::ok = -1; 18 19 struct B 20 { 21 B *ptr; 22 static int ok; 23 24 B () {ptr = this;} 25 ~B () {ok = ptr == this;} 26 }; 27 int B::ok = -1; 28 29 struct C 30 { 31 A volatile a; 32 B volatile b[1]; 33 34 C (); 35 }; 36 37 C::C () 38 { 39 throw 1; 40 } 41 42 int main () 43 { 44 try 45 { 46 C c; 47 } 48 catch (...) 49 { 50 if (A::ok != 1) 51 return 1; 52 if (B::ok != 1) 53 return 2; 54 return 0; 55 } 56 return 3; 57 } 58