Created attachment 42165 [details] Reproducer I have extracted this small snippet (see attached file) from the microblaze-tdep.c source file in GDB. clang gives this warning when passing a non literal to vprintf: $ clang-4.0 test.c -Wformat -Wformat-nonliteral test.c:10:12: warning: format string is not a string literal [-Wformat-nonliteral] vprintf (fmt, args); ^~~ 1 warning generated. gcc 7.2 with the same arguments does not emit any warning. Would it make sense for gcc to also emit it?
Stumbled on this again in the GDB code. Here's another reproducer, probably the same cause: --- #include <string> #include <stdarg.h> void add_line (const std::string &str); void string_vappendf (std::string &str, const char *fmt, va_list args) __attribute__((format(printf, 2, 0))); void print(const char *fmt, ...) { std::string tmp; va_list ap; va_start (ap, fmt); string_vappendf (tmp, fmt, ap); va_end (ap); add_line (tmp); } --- $ g++-9 test.cpp -c -Wall -Wextra -Wformat-nonliteral * no warning * $ clang++-9 test.cpp -c -Wall -Wextra -Wformat-nonliteral test.cpp:13:25: warning: format string is not a string literal [-Wformat-nonliteral] string_vappendf (tmp, fmt, ap); ^~~ 1 warning generated.