http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39438
--- Comment #6 from D. Hugh Redelmeier <hugh at mimosa dot com> --- Responding to Comment 5 by Manuel López-Ibáñez: Thanks for looking at this. > Could you produce a complete testcase === /* compile with -c -Wformat -Werror=format-nonliteral */ #include <time.h> extern void prettynow(char *buf, size_t buflen, const char *fmt, struct tm *t) __attribute__ ((format (__strftime__, 3, 0))); void prettynow(char *buf, size_t buflen, const char *fmt, struct tm *t) { strftime(buf, buflen, fmt, t); } === > The best would be to include only the definitions of the types that you need > > and declare as 'extern' library functions that you use to avoid including > headers. I didn't do this part. My excuses: the type declarations are not portable but the example should be; the solution might be in fixing headers; this way is shorter too. > If you can produce another similar example that works with printf, that would > also help. I don't think that printf is similar enough. A strftime format doesn't interact with varargs in a complex and problematic way. A string, on its own, is or is not a valid strftime format; a string is only a valid printf format when considered with the argument list. If an arg is marked as a const char * (i.e. unchanging) and has the strftime format attribute, it should be accepted as if it were a literal strftime argument. After all, the necessary checking would have been done at this routine's points of call.