Here's a small piece of code:
static struct {
const char fmt[10];
} const x = { "%dn" };
static const char * const fmt = "%dn";
printf(fmt, 1);
printf(x.fmt, 1);
The second printf
produces a warning:
test.c:105:10: warning: format string is not a string literal
[-Wformat-nonliteral]
printf(x.fmt, 1);
^~~~~
From my point of view both format strings are identical. Why can't gcc deduce the format string in the second case?