https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82206

--- Comment #1 from Simon Marchi <simon.marchi at polymtl dot ca> ---
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.

Reply via email to