1// { dg-do run } 2// Bug: g++ re-evaluates the initializer for r before calling f(); since i has 3// changed to an invalid index, this breaks. 4 5class C 6{ 7public: 8 void f () { } 9}; 10 11void foo (C * objs[]) 12{ 13 int i = 0; 14 C & r = * objs[i]; /* make reference to element */ 15 16 i = 666; 17 r.f (); /* core dumps here */ 18} 19 20int 21main () 22{ 23 C * objs[1] = { new C }; 24 25 foo (objs); 26} 27