diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 08bc5ada04d..48163ba05bd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-06-14 Dirk Mueller + + PR c++/31806 + * g++.dg/opt/static6.C: New testcase. + 2007-06-14 Geoff Keating * g++.dg/ext/visibility/overload-1.C: New. diff --git a/gcc/testsuite/g++.dg/opt/static6.C b/gcc/testsuite/g++.dg/opt/static6.C new file mode 100644 index 00000000000..00e76fb7350 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/static6.C @@ -0,0 +1,35 @@ +// PR c++/31806 +// { dg-do run } +// { dg-options "-O2 -fno-inline -fno-threadsafe-statics" } + +extern "C" void abort(void); + +struct A +{ + void *d; +}; + +static const A& staticA() +{ + static A s_static; + return s_static; +} + +void assert_failed() +{ + abort(); +} + +A testMethod() +{ + static const A& s = staticA( ); + if (&s == 0) + assert_failed(); + return s; +} + +int main() +{ + testMethod(); + return 0; +}