[Bug c/77331] incorrect range location in -Wformat with a concatenated format literal

mirq-gccboogs at rere dot qmqm.pl gcc-bugzilla@gcc.gnu.org
Mon May 1 17:18:00 GMT 2017


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

Michał Mirosław <mirq-gccboogs at rere dot qmqm.pl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mirq-gccboogs at rere dot qmqm.pl

--- Comment #1 from Michał Mirosław <mirq-gccboogs at rere dot qmqm.pl> ---
This looks similar (related to PR#52952?): when showing error for concatenated
format string, caret does not point to the triggering format.

void foo(const char *fmt, ...) __attribute__((format(printf, 1, 2)));

#define PREFIX "a:"
#define A(fmt, args...) foo(PREFIX fmt ".", ##args)

void bar()
{
        A("%");
}

$ arm-linux-gnueabihf-gcc-7 -fsyntax-only -Wformat foo.c 

foo.c: In function ‘bar’:
foo.c:3:16: warning: conversion lacks type at end of format [-Wformat=]
 #define PREFIX "a:"
                ^
foo.c:4:29: note: in expansion of macro ‘PREFIX’
 #define A(fmt, args...) foo(PREFIX fmt ".", ##args)
                             ^~~~~~
foo.c:8:2: note: in expansion of macro ‘A’
  A("%");
  ^
foo.c:4:41: note: format string is defined here
 #define A(fmt, args...) foo(PREFIX fmt ".", ##args)
                                         ^

The same happens with gcc-6.3.0.


More information about the Gcc-bugs mailing list