Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / g++.dg / abi / offsetof.C
blobd6a53e6f80a283398867f69e3ab5834373bbd732
1 // Test that we can refer to the address of a base member of a null pointer
2 // to get its offset.  The standard says that offsetof shall not be used on
3 // non-POD classes, but there seems to be no such restriction on the common
4 // implementation thereof.
6 // Yes, this is bad, naughty, evil code.  But it seems to be well-formed.
7 // So we'll just warn.
9 // { dg-do run }
11 struct A { int i; };
13 struct B: public A {
14   virtual void f ();
17 struct C: public B { };
19 int main ()
21   return ((__SIZE_TYPE__) &((C*)0)->i) != sizeof(void*); // { dg-warning "offsetof|invalid" "" }