Bug 13070 - [3.3 regression] -Wformat option ignored in g++
Summary: [3.3 regression] -Wformat option ignored in g++
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3.2
: P2 normal
Target Milestone: 3.3.3
Assignee: Roger Sayle
URL:
Keywords: diagnostic, patch
: 13123 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-11-16 12:33 UTC by Debian GCC Maintainers
Modified: 2003-12-29 06:25 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-12-26 05:48:55


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2003-11-16 12:33:47 UTC
[ 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:~$
Comment 1 Andrew Pinski 2003-11-16 15:19:25 UTC
I can confirm this.
Comment 2 Andrew Pinski 2003-11-19 16:12:39 UTC
*** Bug 13123 has been marked as a duplicate of this bug. ***
Comment 3 janis187 2003-12-10 22:56:57 UTC
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);
}
Comment 4 Andrew Pinski 2003-12-21 20:59:41 UTC
Roger this is caused by your patch would you mind fixing it?
Comment 5 Gabriel Dos Reis 2003-12-24 22:02:36 UTC
Roger --
Do you plan to investigate this?
Comment 6 Andrew Pinski 2003-12-26 05:48:54 UTC
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02076.html>.
Comment 7 GCC Commits 2003-12-28 22:22:16 UTC
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

Comment 8 Andrew Pinski 2003-12-28 23:05:57 UTC
Only a 3.3 Regression now.
Comment 9 GCC Commits 2003-12-29 05:32:37 UTC
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

Comment 10 Andrew Pinski 2003-12-29 06:25:09 UTC
Fixed for 3.3.3 also.