2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / abi / offsetof.C
blob0085e57dd9815e3e9a33c82f0cb3d757b8f261cd
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 ((unsigned long) &((C*)0)->i) != sizeof(void*); // { dg-warning "offsetof|invalid" "" }