summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-float-ref-int-obj.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/warn/Wstrict-aliasing-float-ref-int-obj.C')
-rw-r--r--gcc/testsuite/g++.dg/warn/Wstrict-aliasing-float-ref-int-obj.C12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-float-ref-int-obj.C b/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-float-ref-int-obj.C
new file mode 100644
index 000000000..103248da4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-float-ref-int-obj.C
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wstrict-aliasing -fstrict-aliasing" } */
+
+
+int foo() {
+ int x;
+ float& q = reinterpret_cast<float&> (x); /* { dg-message "dereferencing type-punned" "" { target *-*-* } } */
+ q = 1.0; /* { dg-warning "does break strict-aliasing" "" { xfail *-*-* } } */
+ return x;
+}
+
+/* { dg-message "initialized" "" { xfail *-*-* } 7 } */