https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71501
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |87719 Known to fail|9.0 |10.0, 9.2.0 Summary|missing warning on printf |missing warning on printf |%s with a non-nul |%s with an unterminated |terminated string |array --- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> --- With pr87719 resolved, GCC 10 detects unterminated constant array arguments to printf %s directives, but not the same problem in dynamically constructed arrays. That has to wait until GCC 11. $ cat pr71501.c && gcc -O2 -S -Wall pr71501.c const char a[] = { 'a' }; int main (void) { const char b[] = { 'b' }; __builtin_printf ("a=%s", a); // warning (good) __builtin_printf ("b=%s", b); // missing warning } pr71501.c: In function ‘main’: pr71501.c:7:24: warning: ‘%s’ directive argument is not a nul-terminated string [-Wformat-overflow=] 7 | __builtin_printf ("a=%s", a); // warning (good) | ^~ ~ pr71501.c:1:12: note: referenced argument declared here 1 | const char a[] = { 'a' }; | ^ Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87719 [Bug 87719] missing warning on printf %s and unterminated array