[ forwarded from http://bugs.debian.org/217075 ] The warning is printed, if gcc is used, but not, if g++ is used. I'm confused about the -Wformat behaviour in newer g++ 3.3 releases. It works for plain C, but seems to be ignored for C++ (in some cases at least). Look at this: egon@tuscan:~$ cat testik.cc #include <stdio.h> int main() { printf("%d\n", 1, 1); } egon@tuscan:~$ g++-3.2 -Wformat testik.cc testik.cc: In function `int main()': testik.cc:5: warning: too many arguments for format egon@tuscan:~$ g++-3.3 -Wformat testik.cc egon@tuscan:~$
I can confirm this.
*** Bug 13123 has been marked as a duplicate of this bug. ***
The regression in PR 13070 was introduced or exposed with this patch to both mainline and the 3.3-branch: 2003-03-17 Roger Sayle <roger@eyesopen.com> * decl.c (duplicate_decls): Use the new type when prototyping anticipated decls, even when the types match. This defines the exception list for the built-in function. The regression hunt took place on i686-pc-linux-gnu using the following testcase, modified to not require header files, with -Wformat: extern "C" int printf (const char *, ...); int main () { printf ("%d\n", 1, 1); }
Roger this is caused by your patch would you mind fixing it?
Roger -- Do you plan to investigate this?
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02076.html>.
Subject: Bug 13070 CVSROOT: /cvs/gcc Module name: gcc Changes by: sayle@gcc.gnu.org 2003-12-28 22:22:13 Modified files: gcc/cp : ChangeLog decl.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/warn: format3.C Log message: PR c++/13070 * decl.c (duplicate_decls): When setting the type of an anticipated declaration, merge the existing type attributes. * g++.dg/warn/format3.C: New test case. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3835&r2=1.3836 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1167&r2=1.1168 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3312&r2=1.3313 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/format3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Only a 3.3 Regression now.
Subject: Bug 13070 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: sayle@gcc.gnu.org 2003-12-29 05:32:32 Modified files: gcc/cp : ChangeLog decl.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/warn: format3.C Log message: PR c++/13070 * decl.c (duplicate_decls): When setting the type of an anticipated declaration, merge the existing type attributes. * g++.dg/warn/format3.C: New test case. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.230&r2=1.3076.2.231 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.965.2.67&r2=1.965.2.68 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.346&r2=1.2261.2.347 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/format3.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
Fixed for 3.3.3 also.