[Bug c/71870] wrong location of "%n$" directive in -Wformat
egallager at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Jul 30 12:23:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71870
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-07-30
CC| |egallager at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
Confirmed. Note that the original testcase now prints an additional
-Wformat-overflow warning:
$ /usr/local/bin/gcc -c -Wall -Wextra -Wpedantic -S 71870.c
71870.c: In function ‘f’:
71870.c:5:26: warning: unknown conversion type character ‘r’ in format
[-Wformat=]
__builtin_sprintf (d, "%r");
^
71870.c:7:2: warning: ISO C does not support %n$ operand number formats
[-Wformat=]
__builtin_sprintf (d, "%2$i%1$i", 1, 234);
^~~~~~~~~~~~~~~~~
71870.c:7:33: warning: ‘__builtin_sprintf’ writing a terminating nul past the
end of the destination [-Wformat-overflow=]
__builtin_sprintf (d, "%2$i%1$i", 1, 234);
^
71870.c:7:2: note: ‘__builtin_sprintf’ output 5 bytes into a destination of
size 4
__builtin_sprintf (d, "%2$i%1$i", 1, 234);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$
More information about the Gcc-bugs
mailing list