summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-escape-3.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-escape-3.C')
-rw-r--r--gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-escape-3.C35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-escape-3.C b/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-escape-3.C
new file mode 100644
index 000000000..de6b2c477
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-escape-3.C
@@ -0,0 +1,35 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wstrict-aliasing" } */
+
+struct Node_base {};
+
+struct Node : Node_base
+{
+ int data;
+};
+
+struct List
+{
+ Node_base node, *prev;
+
+ List() : prev(&node) { xyz(); }
+
+ void xyz();
+
+ int back() { return static_cast<Node*>(prev)->data; }
+};
+
+struct A
+{
+ virtual ~A();
+};
+
+A* foo();
+
+void bar()
+{
+ List y;
+ if (y.back())
+ delete foo();
+}
+