https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80537
Bug ID: 80537 Summary: missing -Wformat-overflow on POSIX %C conversion specification Product: gcc Version: 7.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: --- POSIX specifies that the %C conversion specification is equivalent to %lc (used to format wide characters). The -Wformat-overflow doesn't recognize the %C directive and doesn't issue warnings for it. Worse, the directive has the effect of disabling the checking for the rest of the format string. $ cat c.c && gcc -O2 -S -Wall -Wextra -Wpedantic c.c char d[1]; void f (void) { __builtin_sprintf (d + 1, "%lc foo", 'a'); } void g (void) { __builtin_sprintf (d + 1, "%C bar", 'a'); } c.c: In function ‘g’: c.c:10:31: warning: ISO C does not support the ‘%C’ gnu_printf format [-Wformat=] __builtin_sprintf (d + 1, "%C bar", 'a'); ^ c.c: In function ‘f’: c.c:5:30: warning: ‘%lc’ directive writing up to 1 bytes into a region of size 0 [-Wformat-overflow=] __builtin_sprintf (d + 1, "%lc foo", 'a'); ^~~ c.c:5:3: note: ‘__builtin_sprintf’ output between 5 and 6 bytes into a destination of size 0 __builtin_sprintf (d + 1, "%lc foo", 'a'); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~