warning: cannot pass objects of non-POD type class A through ...; call will abort at runtim e
Martin Olsson
martin@minimum.se
Thu Apr 15 16:53:00 GMT 2010
This program:
class A
{
private:
int a;
};
int g(int a, ...) {
return 0;
}
int main(void)
{
A a;
g(1, a);
}
...generates this warning (using gcc 4.4.1 but I think it applies to most
gcc versions):
main.cpp:12: warning: cannot pass objects of non-POD type Âclass AÂ
through Â...Â; call will abort at runtime
1. Why is this a "warning" rather than an "error"? When I run the program
it hits a "ud2a" instruction emitted by gcc and promptly hits SIGILL.
2. Is there a command line switch that I can use to make GCC treat this
particular warning as an error?
3. If I make A::a member public rather than private then A gets classified
as a POD and the warning goes away. I find this a bit strange, because I
always thought that "private" versus "public" was a "compile time concept"
that has no impact on the emitted binary?
Martin
More information about the Gcc-help
mailing list