PR c++/31806
* g++.dg/opt/static6.C: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@125726
138bc75d-0d04-0410-961f-
82ee72b054a4
+2007-06-14 Dirk Mueller <dmueller@suse.de>
+
+ PR c++/31806
+ * g++.dg/opt/static6.C: New testcase.
+
2007-06-14 Geoff Keating <geoffk@apple.com>
* g++.dg/ext/visibility/overload-1.C: New.
--- /dev/null
+// 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;
+}