https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77331
Bug ID: 77331 Summary: incorrect range location in -Wformat with a concatenated format literal 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: --- While getting the latest c-format.c changes integrated into the -Wformat-length pass and testing the result I noticed that GCC underlines different parts of the format strings than shown in the examples in the comment above the definition of the format_warning_va function. The output shown in the comments makes sense. The actual output not so much because parts of the format strings that are unrelated to the problem are underlined. $ cat t.c && /build/gcc-trunk/gcc/xgcc -B /build/gcc-trunk/gcc -S -Wformat -Wformat-signedness t.c extern int printf (const char*, ...); void f (const char *msg) { printf ("hello " "%i", msg); #define INT_FMT "%i" printf ("hello " INT_FMT " world", msg); } t.c: In function ‘f’: t.c:5:11: warning: format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘const char *’ [-Wformat=] printf ("hello " "%i", msg); ^~~~~~~~ t.c:5:22: note: format string is defined here printf ("hello " "%i", msg); ~^ %s t.c:9:11: warning: format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘const char *’ [-Wformat=] printf ("hello " INT_FMT " world", msg); ^~~~~~~~ t.c:7:19: note: format string is defined here #define INT_FMT "%i" ~^ %s