[Bug c/71870] New: wrong location of "%n$" directive in -Wformat
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jul 13 23:09:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71870
Bug ID: 71870
Summary: wrong location of "%n$" directive in -Wformat
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
When encountering an invalid format specifier, the GCC -Wformat checker issues
a warning pointing to the specifier in the format string. However, when it
encounters the dollar sign in an otherwise valid POSIX format directive, GCC
issues a warning that doesn't point to the directive. Modulo the difficulties
discussed in bug 52952 and related there should be no problem pointing to the
'$' in the basic cases similarly to what's done for the 'r' in the test case
below.
$ cat xyz.c && /build/gcc-trunk-svn/gcc/xgcc -B /build/gcc-trunk-svn/gcc -S
-Wall -Wextra -Wpedantic xyz.c
char d [4];
void f (void)
{
__builtin_sprintf (d, "%r");
__builtin_sprintf (d, "%2$i%1$i", 1, 234);
}
xyz.c: In function ‘f’:
xyz.c:5:27: warning: unknown conversion type character ‘r’ in format
[-Wformat=]
__builtin_sprintf (d, "%r");
^
xyz.c:7:3: warning: ISO C does not support %n$ operand number formats
[-Wformat]
__builtin_sprintf (d, "%2$i%1$i", 1, 234);
^~~~~~~~~~~~~~~~~
More information about the Gcc-bugs
mailing list