https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88211
Bug ID: 88211 Summary: missing warning on printf %ls and unterminated wide member array Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- GCC correctly diagnoses the past-the-end read from the narrow character array in f() but fails to diagnose the equivalent past-the-end read from the wide character array in g(). $ cat t.c && gcc -O2 -S -Wall t.c const char a[] = { 'a' }; int f (void) { return __builtin_snprintf (0, 0, "%s", a); // warning (good) } const __WCHAR_TYPE__ wa[] = { L'A' }; int g (void) { return __builtin_snprintf (0, 0, "%ls", wa); // missing warning } t.c: In function āfā: t.c:4:37: warning: ā%sā directive argument is not a nul-terminated string [-Wformat-truncation=] 4 | return __builtin_snprintf (0, 0, "%s", a); // warning (good) | ^~ ~ t.c:1:12: note: referenced argument declared here 1 | const char a[] = { 'a' }; | ^