OSDN Git Service

2004-10-05 Andrew Pinski <pinskia@physics.uc.edu>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / abi / offsetof.C
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.
5
6 // Yes, this is bad, naughty, evil code.  But it seems to be well-formed.
7 // So we'll just warn.
8
9 // { dg-do run }
10
11 struct A { int i; };
12
13 struct B: public A {
14   virtual void f ();
15 };
16
17 struct C: public B { };
18
19 int main ()
20 {
21   return ((unsigned long) &((C*)0)->i) != sizeof(void*); // { dg-warning "offsetof|invalid" "" }
22 }