non-POD type warning with vararg (...)

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

 



Good day all,

The code sample and the non-POD type warning is given at the end of the
message.  I have no problem with the warning, I understand what it means
and what causes it.  (printf is of course declared with a vararg
argument)

gcc does produce an executable, which then segfaults with a core dump at
the warning line.

My question is this: How can I force gcc to promote this warning to an
error ?  I'd rather find errors like these at compile time, before my
customers get code that will segfault.

IMHO this is serious -- why is it only a warning that tells you your
code WILL abort at run-time?  Surely this should have been an error in
the first place?

Thanks in advance.

Lourens...

--------
example
--------
$ cat a.cpp

#include <string>
#include <stdio.h>

int main()
{
        std::string sss="Hello World!";

        printf ("String is: %s\n", sss);

        return 0;
}

$ g++ a.cpp
a.cpp: In function `int main()':
a.cpp:8: warning: cannot pass objects of non-POD type `struct
std::string'
   through `...'; call will abort at runtime

$ ./a.out
Segmentation fault (core dumped)


[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