[Bug c/77328] incorrect caret location in -Wformat calling printf via a macro
egallager at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Oct 31 04:24:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77328
--- Comment #4 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #3)
> GCC 8 and 9 output for the test case is slightly different (underlining the
> sprintf argument is a nice improvement) but still not what it should be:
>
> pr77328.c: In function ‘f’:
> pr77328.c:7:30: warning: format ‘%i’ expects argument of type ‘int’, but
> argument 4 has type ‘double’ [-Wformat=]
> __builtin_sprintf (d, "%i %i", 1, 2.0);
> ~^ ~~~
> %f
> pr77328.c:9:9: warning: format ‘%i’ expects argument of type ‘int’, but
> argument 4 has type ‘double’ [-Wformat=]
> P (d, "%i %i", 1, 2.0);
> ^~~~~~~ ~~~
> pr77328.c:5:45: note: in definition of macro ‘P’
> #define P(d, f, a, b) __builtin_sprintf (d, f, a, b)
> ^
With gcc 10 it's now:
$ /usr/local/bin/gcc -c -S -Wformat 77328.c
77328.c: In function 'f':
77328.c:7:29: warning: format '%i' expects argument of type 'int', but argument
4 has type 'double' [-Wformat=]
7 | __builtin_sprintf (d, "%i %i", 1, 2.0);
| ~^ ~~~
| | |
| int double
| %f
77328.c:9:8: warning: format '%i' expects argument of type 'int', but argument
4 has type 'double' [-Wformat=]
9 | P (d, "%i %i", 1, 2.0);
| ^~~~~~~ ~~~
| |
| double
77328.c:5:45: note: in definition of macro 'P'
5 | #define P(d, f, a, b) __builtin_sprintf (d, f, a, b)
| ^
77328.c:9:13: note: format string is defined here
9 | P (d, "%i %i", 1, 2.0);
| ~^
| |
| int
| %f
$
More information about the Gcc-bugs
mailing list