Debian Codegraph @

gcc/testsuite/g++.dg/warn/Waddress-of-packed-member3.C

raw
1 // { dg-do compile { target { ! default_packed } } }
2 // { dg-additional-options -Wcast-align=strict }
3
4 struct S {
5 char c;
6 } __attribute__((packed));
7
8 struct X {
9 S* memfn ();
10 static S* smemfn ();
11 } x;
12
13 S *foo ();
14
15 S**
16 f ()
17 {
18 S **s;
19 s = reinterpret_cast<S**>(foo ()); // { dg-warning "increases required alignment" }
20 s = reinterpret_cast<S**>(x.memfn ()); // { dg-warning "increases required alignment" }
21 s = reinterpret_cast<S**>(X::smemfn ()); // { dg-warning "increases required alignment" }
22 return s;
23 }