[Bug c/52952] Wformat location info is bad (wrong column number)
manu at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Sep 16 19:38:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52952
--- Comment #51 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
There are few things still that don't work:
1. C++ does not work
2. Locations within strings expanded from a macro
3. Location within strings from a const char array.
void foo(void) {
#define c " %d %d "
__builtin_printf(c, 0.5, 0);
const char a[] = " %d ";
__builtin_printf(a, 0.5);
}
GCC 9:
<source>:2:25: error: format '%d' expects argument of type 'int', but argument
2 has type 'double' [-Werror=format=]
2 | #define c " %d %d "
| ^~~~~~~~~
<source>:3:20: note: in expansion of macro 'c'
3 | __builtin_printf(c, 0.5, 0);
| ^
<source>:6:20: error: format '%d' expects argument of type 'int', but argument
2 has type 'double' [-Werror=format=]
6 | __builtin_printf(a, 0.5);
| ^ ~~~
| |
| double
Clang can do (3) but not (2):
<source>:3:23: error: format specifies type 'int' but the argument has type
'double' [-Werror,-Wformat]
__builtin_printf(c, 0.5, 0);
~ ^~~
<source>:6:23: error: format specifies type 'int' but the argument has type
'double' [-Werror,-Wformat]
__builtin_printf(a, 0.5);
~ ^~~
<source>:5:22: note: format string is defined here
const char a[] = " %d ";
^~
%f
More information about the Gcc-bugs
mailing list