[Bug c/85948] New: printf format attribute warning line carat inaccurate
jg at jguk dot org
gcc-bugzilla@gcc.gnu.org
Mon May 28 11:35:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85948
Bug ID: 85948
Summary: printf format attribute warning line carat inaccurate
Product: gcc
Version: 8.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jg at jguk dot org
Target Milestone: ---
Created attachment 44194
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44194&action=edit
main
Reproduced in 8.1 and 5.4
1. I noticed the line carat 9 below is not accurate for the printf format
specifier
2. The later two also has missing carat lines.
3. Output below, and then expected output aafter
Output:
$ gcc -o main main.c -Wall -Werror -Wconversion
main.c: In function ‘main’:
main.c:19:9: error: format ‘%s’ expects argument of type ‘char *’, but argument
2 has type ‘int’ [-Werror=format=]
str_fmt("%s %zu %s %s", d, str, str, d);
^
main.c:19:9: error: format ‘%zu’ expects argument of type ‘size_t’, but
argument 3 has type ‘const char *’ [-Werror=format=]
main.c:19:9: error: format ‘%s’ expects argument of type ‘char *’, but argument
5 has type ‘int’ [-Werror=format=]
cc1: all warnings being treated as errors
Expected:
$ gcc -o main main.c -Wall -Werror -Wconversion
main.c: In function ‘main’:
main.c:19:10: error: format ‘%s’ expects argument of type ‘char *’, but
argument 2 has type ‘int’ [-Werror=format=]
str_fmt("%s %zu %s %s", d, str, str, d);
^
main.c:19:13: error: format ‘%zu’ expects argument of type ‘size_t’, but
argument 3 has type ‘const char *’ [-Werror=format=]
str_fmt("%s %zu %s %s", d, str, str, d);
^
main.c:19:20: error: format ‘%s’ expects argument of type ‘char *’, but
argument 5 has type ‘int’ [-Werror=format=]
str_fmt("%s %zu %s %s", d, str, str, d);
^
cc1: all warnings being treated as errors
More information about the Gcc-bugs
mailing list