-Wall option doesn't include -Wformat completely in gcc version 2.95.3 20010315 (release) [FreeBSD] on FreeBSD 4.4-RC

Andrey Simonenko simon@comsys.ntu-kpi.kiev.ua
Wed Sep 12 01:00:00 GMT 2001


I found problem with -Wall and think that this is a bug of GCC.
This is simple C source check.c:

#include <stdio.h>
#include <stdarg.h>

#ifdef __GNUC__
static void my_printf(const char *, ...) __attribute__ ((format (printf, 1,
2)));
#endif

void
my_printf(const char *format, ...)
{
 va_list  ap;

 vprintf(format, ap);
 va_end(ap);
}

int
main()
{
 char name[] = "Nick";

 my_printf("hello %s %s\n", name);
 my_printf("hello\n", name);
 return 0;
}

I call function my_printf two times and each time pass incorrect
printf-like string to my_printf().

Command:

gcc -Wall -O0 -o check1 check.c

doesn't report any worning messages about first line

but command

gcc -Wall -Wformat -O0 -o check2 check.c

reports two warning messages.

I think it is a bug, because -Wall should include -Wformat. I found
this bug on:

FreeBSD/i386 4.4-RC
Using builtin specs.
gcc version 2.95.3 20010315 (release) [FreeBSD]

But on following systems I don't see this bug (both "make" commands
report two warnings messages):

FreeBSD/i386 4.3-STABLE
Using builtin specs.
gcc version 2.95.3 [FreeBSD] 20010315 (release)

FreeBSD/i386 3.4-STABLE
gcc version 2.7.2.3





More information about the Gcc-bugs mailing list