This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/57137] spurious "format string is not literal" when the format string is marked with __attribute__((format))


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");
   ^

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]