gcc vs g++ format string warning question

llewelly@xmission.com llewelly@xmission.com
Wed Apr 28 00:25:00 GMT 2004


Scott Lipcon <slipcon@mercea.net> writes:

> 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++?

It's a bug, fixed in 3.3.3 and 3.4 . See
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13507



More information about the Gcc-help mailing list