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

* [Bug c/64955] RFE: have -Wformat suggest the correct format string to use
  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 ` manu at gcc dot gnu.org
  2015-10-21 22:49 ` msebor at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: manu at gcc dot gnu.org @ 2015-02-27 15:18 UTC (permalink / raw)
  To: gcc-bugs

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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-02-27
                 CC|                            |manu at gcc dot gnu.org
          Component|c++                         |c
     Ever confirmed|0                           |1

--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to David Malcolm from comment #0)
> Currently, -Wformat tells me that I got something wrong but doesn't tell we
> what the correct format string is:

I think this should not be hard given the tables already available when
checking formats. This could be an EasyHack.

About generating a patch, we would first need precise locations within format
strings (PR52952), then implement the fix-it hints (PR62314) and editors like
Emacs could parse them to patch the code. Unfortunately, the time I can
dedicate to GCC has been very much reduced lately and I haven't been able to
find anyone to continue this work.
>From gcc-bugs-return-478745-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Feb 27 14:56:40 2015
Return-Path: <gcc-bugs-return-478745-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 101075 invoked by alias); 27 Feb 2015 14:56:40 -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 101005 invoked by uid 48); 27 Feb 2015 14:56:35 -0000
From: "jakub 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: Fri, 27 Feb 2015 15:23: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: diagnostic
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: jakub at gcc dot gnu.org
X-Bugzilla-Status: NEW
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: cc
Message-ID: <bug-64955-4-tyrhES7Uy6@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/msg03077.txt.bz2
Content-length: 734

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The problem here is that usually there are more possibilities of fixing the
code, and so it is a question what to suggest, it might as well just annoy
users when it constantly suggests the opposite hint the user wants to take.  In
some cases, it is desirable to change the format specifier, in others to change
the argument (cast it to something, ...), etc.


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

* [Bug c/64955] RFE: have -Wformat suggest the correct format string to use
  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
  1 sibling, 0 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2015-10-21 22:49 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
FWIW, if printing a new note is a concern, perhaps simply enhancing the
existing warning to mention the appropriate format specifier for the type along
the following lines might be less nannying:

warning: format ‘%i’ expects argument of type ‘int’, but argument 2 has type
‘long long int’ which requires ’%lli’ [-Wformat=]
>From gcc-bugs-return-500232-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Oct 21 22:53:23 2015
Return-Path: <gcc-bugs-return-500232-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 61024 invoked by alias); 21 Oct 2015 22:53:23 -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 60940 invoked by uid 55); 21 Oct 2015 22:53:19 -0000
From: "paolo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/67847] ICE on (invalid) nested enum declaration on x86_64-linux-gnu in is_ancestor, at cp/name-lookup.c:2771
Date: Wed, 21 Oct 2015 22:53: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: 6.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: paolo at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: paolo.carlini at oracle dot com
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-67847-4-l53yCoL1io@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-67847-4@http.gcc.gnu.org/bugzilla/>
References: <bug-67847-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-10/txt/msg01787.txt.bz2
Content-length: 1139

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

--- Comment #2 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Wed Oct 21 22:52:45 2015
New Revision: 229156

URL: https://gcc.gnu.org/viewcvs?rev"9156&root=gcc&view=rev
Log:
/cp
2015-10-21  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/66781
        * parser.c (cp_parser_enum_specifier): Upon error_at set
        nested_name_specifier to error_mark_node; improve error message.

/testsuite
2015-10-21  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/66781
        * g++.dg/parse/enum13.C: New.

/cp
2015-10-21  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/67847
        * parser.c (cp_parser_enum_specifier): Reject a nested_name_specifier
        which doesn't name a class or namespace.

/testsuite
2015-10-21  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/67847
        * g++.dg/parse/enum12.C: New.


Added:
    trunk/gcc/testsuite/g++.dg/parse/enum12.C
    trunk/gcc/testsuite/g++.dg/parse/enum13.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog


^ 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).