invalid offsetof from non-POD type
Gabriel Dos Reis
gdr@integrable-solutions.net
Mon Apr 21 14:30:00 GMT 2003
John Quigley <johnw@lowestplane.org> writes:
| The code below triggers an "invalid offsetof from non-POD type" warning:
The compiler is right.
| In this case, and in every case I've seen, the warning is a false alarm and
No, that is not false alarm. Your class Foo is *not* a POD, and as
such your program, technically, invokes undefined behaviour.
[...]
| class Foo
| {
| public:
| int x;
| char fillerdata[256];
| int y;
|
| Foo()
^^^^^
Your class has a user-defined constructor, therefore it certainly
cannot not be a POD. Hence the warning.
(if it were only me, I would issue a hard error and halt translation.)
-- Gaby
More information about the Gcc
mailing list