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

            Bug ID: 71863
           Summary: wrong column location in -Wformat in C++
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

When compiled in C mode, the following test emits warnings that point at each
of the problem directives:

$ cat xyz.c && /build/gcc-trunk-svn/gcc/xgcc -B /build/gcc-trunk-svn/gcc -S
-Wformat xyz.c
void f (void)
{
  __builtin_printf ("%s%s", 0, 0);
}
xyz.c: In function ‘f’:
xyz.c:3:23: warning: format ‘%s’ expects argument of type ‘char *’, but
argument 2 has type ‘int’ [-Wformat=]
   __builtin_printf ("%s%s", 0, 0);
                       ^
xyz.c:3:25: warning: format ‘%s’ expects argument of type ‘char *’, but
argument 3 has type ‘int’ [-Wformat=]
   __builtin_printf ("%s%s", 0, 0);
                         ^

However, when compiled in C++ mode, the column information is wrong:

$ cat xyz.c && /build/gcc-trunk-svn/gcc/xgcc -B /build/gcc-trunk-svn/gcc -S
-Wformat -xc++ xyz.c
void f (void)
{
  __builtin_printf ("%s%s", 0, 0);
}
xyz.c: In function ‘void f()’:
xyz.c:3:33: warning: format ‘%s’ expects argument of type ‘char*’, but argument
2 has type ‘int’ [-Wformat=]
   __builtin_printf ("%s%s", 0, 0);
                                 ^
xyz.c:3:33: warning: format ‘%s’ expects argument of type ‘char*’, but argument
3 has type ‘int’ [-Wformat=]

The same problem occurs with other directives.  I found a long discussion of
some of the issues in bug 52952 but based on the patches referenced from there
it looks like they have been resolved (as least for C).

Reply via email to