re PR tree-optimization/38937 (dereferencing pointer '<anonymous>' does break strict...
authorRichard Guenther <rguenther@suse.de>
Mon, 2 Feb 2009 10:39:12 +0000 (10:39 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 2 Feb 2009 10:39:12 +0000 (10:39 +0000)
2009-02-02  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/38937
* g++.dg/warn/Wstrict-aliasing-bogus-escape.C: New testcase.

From-SVN: r143864

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-escape.C [new file with mode: 0644]

index d5040061715f1516e544d51f917f0b0a74963829..249f717fd4d4166da35271558863caf1e1de0100 100644 (file)
@@ -1,3 +1,8 @@
+2009-02-02  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/38937
+       * g++.dg/warn/Wstrict-aliasing-bogus-escape.C: New testcase.
+
 2009-02-01  Paolo Carlini  <paolo.carlini@oracle.com>
 
         PR c++/39053
diff --git a/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-escape.C b/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-escape.C
new file mode 100644 (file)
index 0000000..9ea6198
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wstrict-aliasing" } */
+
+#include <string>
+#include <list>
+
+class A;
+
+class B {
+public:
+    void foo(A&);
+    std::string s;
+};
+
+class A {
+public:
+    A& qaz() {
+       l.push_back( new A() );
+       return *l.back();
+    }
+    std::list<A*> l;
+};
+
+void bar()
+{
+  A a;
+  B b;
+  b.foo(a.qaz());
+}
+