[Bug c/86102] Include argument name in warning
jg at jguk dot org
gcc-bugzilla@gcc.gnu.org
Sun Jun 10 20:08:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86102
--- Comment #2 from Jonny Grant <jg at jguk dot org> ---
My bad apologies, I pasted the wrong compiler output from older gcc
If I fix that const error in my sample, I get same output as you, with correct
carat.
Could I check - do you mean callnig a function like
printf("result: %zu %zu %zu\n", value, "test", str);
There is no benefit from displaying 'value' '"test"' or 'str' ?
Some functions might have 10 arguments.. much clearer to print the name of the
one that is bad I feel :)
<source>: In function 'int main()':
<source>:9:12: error: format '%zu' expects argument of type 'size_t', but
argument 3 has type 'const char*' [-Werror=format=]
printf("result: %zu %zu %zu\n", value, "test", str);
^~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
<source>:9:12: error: format '%zu' expects argument of type 'size_t', but
argument 4 has type 'const char*' [-Werror=format=]
cc1plus: all warnings being treated as errors
Compiler returned: 1
//gcc -O2 -Wall -Wextra -Wpedantic -o main main.c
#include <stdio.h>
int main (void)
{
size_t value = 0;
const char * str = "other";
printf("result: %zu %zu %zu\n", value, "test", str);
return 0;
}
More information about the Gcc-bugs
mailing list