re PR c++/31806 (miscompilation with -fschedule-insns2 -fno-threadsafe-statics)
authorDirk Mueller <dmueller@suse.de>
Thu, 14 Jun 2007 23:12:25 +0000 (23:12 +0000)
committerDirk Mueller <mueller@gcc.gnu.org>
Thu, 14 Jun 2007 23:12:25 +0000 (23:12 +0000)
2007-06-14  Dirk Mueller  <dmueller@suse.de>

       PR c++/31806
       * g++.dg/opt/static6.C: New testcase.

From-SVN: r125726

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/static6.C [new file with mode: 0644]

index 08bc5ada04deef0379b723c74152cc41a090d18c..48163ba05bd6cff92b30de720a2a76803b6393c3 100644 (file)
@@ -1,3 +1,8 @@
+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.
diff --git a/gcc/testsuite/g++.dg/opt/static6.C b/gcc/testsuite/g++.dg/opt/static6.C
new file mode 100644 (file)
index 0000000..00e76fb
--- /dev/null
@@ -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;
+}