gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-escape.C
raw| 1 | /* { dg-do compile } */ |
| 2 | /* { dg-options "-O2 -Wstrict-aliasing" } */ |
| 3 | /* { dg-skip-if "requires hosted libstdc++ for string" { ! hostedlib } } */ |
| 4 | |
| 5 | #include <string> |
| 6 | #include <list> |
| 7 | |
| 8 | class A; |
| 9 | |
| 10 | class B { |
| 11 | public: |
| 12 | void foo(A&); |
| 13 | std::string s; |
| 14 | }; |
| 15 | |
| 16 | class A { |
| 17 | public: |
| 18 | A& qaz() { |
| 19 | l.push_back( new A() ); |
| 20 | return *l.back(); |
| 21 | } |
| 22 | std::list<A*> l; |
| 23 | }; |
| 24 | |
| 25 | void bar() |
| 26 | { |
| 27 | A a; |
| 28 | B b; |
| 29 | b.foo(a.qaz()); |
| 30 | } |
| 31 |