This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
non-POD type warning with vararg (...)
- From: "Lourens Janse van Rensburg" <Lourens dot jansevanRensburg at intec dot co dot za>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Wed, 20 Oct 2004 15:55:28 +0200
- Subject: non-POD type warning with vararg (...)
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)