gcc vs g++ format string warning question

Scott Lipcon slipcon@mercea.net
Tue Apr 27 17:14:00 GMT 2004


Hi,

I've got a very simple test program:

#include <stdio.h>
int main(int argc, char** argv)
{
  printf("%s $s\n", "foo", "bar");
  return 0;
}

which resulted from a typo in a format string ($s instead of %s).
Logic would say that this would result in a warning about the format
string having too many arguments, and using gcc (3.3.2) it does:

> gcc -Wall -Werror -o try-too-many try-too-many.c
try-too-many.c: In function `main':
try-too-many.c:5: warning: too many arguments for format
>

however, using g++ (also 3.3.2), there is no warning:

> g++ -Wall -Werror -o try-too-many try-too-many.c
>

I just tried this again with gcc/g++ 3.4.0 and both produce the
expected warning.  Is this a bug in 3.3.2, or is there another warning
I need to enable for g++?

please cc any replies to me as I'm not subscribed.

Thanks,

Scott Lipcon



More information about the Gcc-help mailing list