This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/57137] spurious "format string is not literal" when the format string is marked with __attribute__((format))
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 22 Apr 2016 23:14:42 +0000
- Subject: [Bug c/57137] spurious "format string is not literal" when the format string is marked with __attribute__((format))
- Auto-submitted: auto-generated
- References: <bug-57137-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57137
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2016-04-22
CC| |msebor at gcc dot gnu.org
Ever confirmed|0 |1
Known to fail| |4.9.3, 5.3.0, 6.0
--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed. In addition, as the example below illustrates, the warning in this
case is issued for the call where it could be avoided (in function g) and not
for the call that should be diagnosed (in function h).
$ cat v.c && gcc -S -Wformat -Wformat-nonliteral v.c
void f (const char*, ...) __attribute__ ((format (printf, 1, 2)));
void g (const char*) __attribute__ ((format (printf, 1, 0)));
void g (const char *fmt)
{
f (fmt, "xxx");
}
void h (const char *fmt)
{
g (fmt);
}
v.c: In function âgâ:
v.c:6:3: warning: format not a string literal, argument types not checked
[-Wformat-nonliteral]
f (fmt, "xxx");
^