diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-base-derived.C')
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-base-derived.C | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-base-derived.C b/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-base-derived.C new file mode 100644 index 000000000..18e6caf90 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-base-derived.C @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-aliasing -fstrict-aliasing" } */ + + +class base { + public: + int x; +}; + +class derived: public base { + public: + int y; +}; + +base foo () { + derived d; + base* pb = &d; /* { dg-bogus "base vs. derived" } */ + pb->x = 1; + + return d; +} |