gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-union-2.C
raw| 1 | /* { dg-do compile { target c++11 } } */ |
| 2 | /* { dg-options "-Wstrict-aliasing=2 -O2 -Wall" } */ |
| 3 | |
| 4 | #include <type_traits> |
| 5 | |
| 6 | struct foo |
| 7 | { |
| 8 | std::aligned_storage<sizeof(long), alignof(long)>::type raw; /* { dg-warning "deprecated" "" { target c++23 } } */ |
| 9 | |
| 10 | long& cooked() |
| 11 | { |
| 12 | return *static_cast<long*>(static_cast<void*>(&raw)); /* { dg-bogus "strict-aliasing" } */ |
| 13 | } |
| 14 | }; |