This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
warning: cannot pass objects of non-POD type ?class A? through ?...?; call will abort at runtim e
- From: "Martin Olsson" <martin at minimum dot se>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 15 Apr 2010 18:24:28 +0200 (CEST)
- Subject: warning: cannot pass objects of non-POD type ?class A? through ?...?; call will abort at runtim e
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