public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64955] New: RFE: have -Wformat suggest the correct format string to use
@ 2015-02-05 21:33 dmalcolm at gcc dot gnu.org
  2015-02-27 15:18 ` [Bug c/64955] " manu at gcc dot gnu.org
  2015-10-21 22:49 ` msebor at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2015-02-05 21:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64955

            Bug ID: 64955
           Summary: RFE: have -Wformat suggest the correct format string
                    to use
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org

Currently, -Wformat tells me that I got something wrong but doesn't tell we
what the correct format string is:

$ ./xgcc --version
xgcc (GCC) 5.0.0 20150204 (experimental)
(etc)

$ cat test.c
#include <stdio.h>

void test (long long ll)
{
  printf ("%i\n", ll);
}


$ ./xgcc -c -B. test.c -Wformat
test.c: In function ‘test’:
test.c:5:11: warning: format ‘%i’ expects argument of type ‘int’, but argument
2 has type ‘long long int’ [-Wformat=]
   printf ("%i\n", ll);
           ^

It would be helpful if gcc could emit something like:
test.c:5:11: note: ‘printf‘ expects format string ‘%lli’ for type ‘long long
int’.

and maybe, if it can't be handled:
test.c:5:11: note: ‘printf‘ does not have a format string for handling type
‘struct foo’.

as an additional clarifying note after the warning/error

(Bonus points: have GCC generate a patch to fix it ;) )
>From gcc-bugs-return-476183-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Feb 05 21:39:15 2015
Return-Path: <gcc-bugs-return-476183-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 19868 invoked by alias); 5 Feb 2015 21:39:14 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 16081 invoked by uid 48); 5 Feb 2015 21:39:11 -0000
From: "dmalcolm at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/64955] RFE: have -Wformat suggest the correct format string to use
Date: Thu, 05 Feb 2015 21:39:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: dmalcolm at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_severity
Message-ID: <bug-64955-4-e1SoXA4yio@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64955-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64955-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-02/txt/msg00516.txt.bz2
Content-length: 300

https://gcc.gnu.org/bugzilla/show_bug.cgi?idd955

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-21 22:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-05 21:33 [Bug c++/64955] New: RFE: have -Wformat suggest the correct format string to use dmalcolm at gcc dot gnu.org
2015-02-27 15:18 ` [Bug c/64955] " manu at gcc dot gnu.org
2015-10-21 22:49 ` msebor at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).