https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87144
Bug ID: 87144
Summary: missing -Wformat for mismatched argument type
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
GCC fails to diagnose the argument mismatch below. -Wformat runs too early to
detect it but the snprintf pass could do it.
$ cat f.c && gcc -O2 -S -Wall f.c
int f (_Bool str, int x, const char *s)
{
const char *f = str ? "%s" : "%i";
// Note the typo in the ternary operator below: it should be
// str ? s : x);
// instead.
return __builtin_snprintf (0, 0, f, s ? str : x);
}