invalid offsetof from non-POD type

Joe Buck jbuck@synopsys.com
Tue Apr 22 19:35:00 GMT 2003


On Tue, Apr 22, 2003 at 10:19:03AM -0700, Zack Weinberg wrote:
> Suppose the following definition:
> 
> For any object X of type T with data member m of type t, 
> offsetof(T, m) is defined to be a value of type ptrdiff_t which
> satisfies the equation
> 
>     (t *)((char *)&X + offsetof(T, m)) == &X.m

Try it a different way: type T is a struct or class type that does not
have any direct or indirect virtual base classes.  type t is not a
reference, and it is not an empty class or struct.  In all such cases (at
least for the GCC implementation) type T is then laid out in one unit, and
the offset of m is uniquely defined.



More information about the Gcc mailing list