warning: cannot pass objects of non-POD type ?class A? through ?...?; call will abort at runtim e

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux