[Bug c++/56856] the location of Wformat warnings points *after* the format string

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jul 13 19:26:00 GMT 2016


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

--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
I thought I'd look into this bug since it affects the testing of my patch for
bug 49905 and I'm finding out that it seems to be a general problem with C++
and function arguments.  From what I can see, the C front end tracks the
locations of function arguments through the parser, passing them from function
to function, while the C++ front end doesn't.  Sadly, it doesn't look like a
simple fix...

$ cat xyz.c && /build/gcc-trunk-svn/gcc/xgcc -B /build/gcc-trunk-svn/gcc -S
-Wall -Wextra -Wpedantic -Wformat -xc++ xyz.c
void f (int, int, int);

void g (void)
{
  f (0, "", 1);
}
xyz.c: In function ‘void g()’:
xyz.c:5:14: error: invalid conversion from ‘const char*’ to ‘int’
[-fpermissive]
   f (0, "", 1);
              ^
xyz.c:1:6: note:   initializing argument 2 of ‘void f(int, int, int)’
 void f (int, int, int);
      ^


More information about the Gcc-bugs mailing list