https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91599
Bug ID: 91599 Summary: GCC does not say where warning is happening Product: gcc Version: unknown Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: sje at gcc dot gnu.org Target Milestone: --- When compiling the following source file, GCC gives a warning. The warning notes that the declaration is on line 2 but it does not say what line the actual write is on (line 12). This message started showing up with Martin Sebor's patch for PR c++/83431 though I don't know if he added it or if he just made it show up in places where it wasn't happening before. % cat x.c struct charseq { unsigned char bytes[0]; }; struct locale_ctype_t { struct charseq *mboutdigits[10]; }; void ctype_finish (struct locale_ctype_t *ctype) { long unsigned int cnt; for (cnt = 0; cnt < 20; ++cnt) { static struct charseq replace[2]; replace[0].bytes[1] = '\0'; ctype->mboutdigits[cnt] = &replace[0]; } } % install/bin/gcc -O2 -c x.c x.c: In function ‘ctype_finish’: cc1: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] x.c:2:18: note: destination object declared here 2 | unsigned char bytes[0]; | It would be nice if the warning said the write was on line 12 as well as saying that the declaration is on line 2. This test case is cutdown from code in glibc where the code doing the write was less easy to find.