This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/44513] improve column number and text of format warnings


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44513

Nicola Pero <nicola at gcc dot gnu.org> changed:

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

--- Comment #1 from Nicola Pero <nicola at gcc dot gnu.org> 2011-01-17 23:48:16 UTC ---
I tested GCC 4.6.0, and it seems to have been modified to match what you
want:

cat -n test.c
    1  #include "stdio.h"
    2
    3  void
    4  foo (int i)
    5  {
    6    printf ("%d%d", i); 
    7  }

gcc test.c -c -Wall
test.c: In function âfooâ:
test.c:6:3: warning: format â%dâ expects a matching âintâ argument [-Wformat]

I personally preferred GCC's original error message; when you have lots of 
arguments, the new system will generate lots of error messages, all of them
technically correct, but providing a confusing picture.  Eg,

void foo (int i, float f, int j, float c)
{
  printf ("%d%f%d%f", f, j, c);
}

(where the missing argument is the first one) will generate 4 error messages
now:

test.c: In function âfooâ:
test.c:5:3: warning: format â%dâ expects argument of type âintâ, but argument 2
has type âdoubleâ [-Wformat]
test.c:5:3: warning: format â%fâ expects argument of type âdoubleâ, but
argument 3 has type âintâ [-Wformat]
test.c:5:3: warning: format â%dâ expects argument of type âintâ, but argument 4
has type âdoubleâ [-Wformat]
test.c:5:3: warning: format â%fâ expects a matching âdoubleâ argument
[-Wformat]

In this context, I would prefer the traditional GCC error message ("too few
arguments"), which is a simple, clear summary of the problem.

Thanks


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]