https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87757
Bug ID: 87757 Summary: weird underlining and colors in sprintf warnings for unterminated arrays 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 produces slightly different output for the two equivalent calls to sprintf below. The underlining for the second call looks wrong, as does its color: it's green. $ cat t.c && gcc -O2 -S -Wall t.c const char a[] = { 'a' }; char *d, *e; void f (void) { __builtin_sprintf (d, "%s", a); __builtin_sprintf (e, "%s", &a[0]); } t.c: In function ‘f’: t.c:7:26: warning: ‘%s’ directive argument is not a nul-terminated string [-Wformat-overflow=] 7 | __builtin_sprintf (d, "%s", a); | ^~ ~ t.c:1:12: note: referenced argument declared here 1 | const char a[] = { 'a' }; | ^ t.c:8:26: warning: ‘%s’ directive argument is not a nul-terminated string [-Wformat-overflow=] 8 | __builtin_sprintf (e, "%s", &a[0]); | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ t.c:1:12: note: referenced argument declared here 1 | const char a[] = { 'a' }; | ^