Debian Codegraph @

gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-char-2.C

raw
1 // { dg-do compile }
2 // { dg-options "-O2 -Wstrict-aliasing" }
3
4 template<unsigned _Len, unsigned _Align>
5 struct aligned_storage
6 {
7 union type
8 {
9 unsigned char __data[_Len];
10 struct __attribute__((__aligned__((_Align)))) { } __align;
11 };
12 };
13
14 aligned_storage<sizeof(int), __alignof__(int)>::type storage;
15
16 int main()
17 {
18 *reinterpret_cast<int*>(&storage) = 42; // { dg-bogus "break strict-aliasing" }
19 }