https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79538
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2017-03-13 Summary|missing -Wformat-overflow |missing -Wformat-overflow |with %s and global array |with %s and non-member |arguments |array arguments Ever confirmed|0 |1 --- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- Confirming my own bug and adjusting the Summary to make it clear that the problem isn't specific to global arrays and affects local arrays as well. The following test case shows that. $ cat z.c && gcc -O2 -S -Wall -Wextra -Wpedantic -fdump-tree-printf-return-value=/dev/stdout z.c int main () { char d[3]; char s[] = "abcd"; __builtin_sprintf (d, "%-s", s); __builtin_printf ("%s\n", d); } ;; Function main (main, funcdef_no=0, decl_uid=1794, cgraph_uid=0, symbol_order=0) (executed once) z.c:6: __builtin_sprintf: objsize = 3, fmtstr = "%-s" Directive 1 at offset 0: "%-s" Result: 0, 0, -1, 9223372036854775807 (0, 0, -1, -1) Directive 2 at offset 3: "", length = 1 main () { char s[5]; char d[3]; <bb 2> [100.00%]: s = "abcd"; __builtin_sprintf (&d, "%-s", &s); __builtin_puts (&d); d ={v} {CLOBBER}; s ={v} {CLOBBER}; return 0; }