[Bug c/106039] Inconsistent error reporting for printf() when format string is a macro
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jun 21 01:10:38 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106039
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I don't see an issue with the diagnostic here really.
For the single line case (without the format as a macro):
printf("%-21s %-16x %-16x %-18s %-18s\n", "GHI", (intptr_t) val1,
(intptr_t) val1, "ABC", "DEF");
We get:
<source>:22:23: warning: format '%x' expects argument of type 'unsigned int',
but argument 3 has type 'long int' [-Wformat=]
22 | printf("%-21s %-16x %-16x %-18s %-18s\n", "GHI", (intptr_t) val1,
(intptr_t) val1, "ABC", "DEF");
| ~~~~^ ~~~~~~~~~~~~~~~
| | |
| unsigned int long int
| %-16lx
<source>:22:29: warning: format '%x' expects argument of type 'unsigned int',
but argument 4 has type 'long int' [-Wformat=]
22 | printf("%-21s %-16x %-16x %-18s %-18s\n", "GHI", (intptr_t) val1,
(intptr_t) val1, "ABC", "DEF");
| ~~~~^
~~~~~~~~~~~~~~~
| | |
| unsigned int
long int
| %-16lx
are you asking to point out where the arguments were for the macro case?
More information about the Gcc-bugs
mailing list