Debian Codegraph @

gcc/testsuite/g++.dg/other/offsetof9.C

raw
1 // PR c++/68727
2 // { dg-do compile }
3 // { dg-options "-Winvalid-offsetof" }
4
5 struct A { int i; };
6 struct B : virtual A { };
7 __SIZE_TYPE__ s = __builtin_offsetof (B, A::i); // { dg-warning "'offsetof' within non-standard-layout type" }
8
9 template <typename T>
10 __SIZE_TYPE__
11 foo ()
12 {
13 return __builtin_offsetof (T, A::i) // { dg-warning "'offsetof' within non-standard-layout type" }
14 + __builtin_offsetof (B, A::i); // { dg-warning "'offsetof' within non-standard-layout type" }
15 }
16
17 __SIZE_TYPE__ t = foo<B> ();