https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100137
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot
gnu.org
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
The warning bug was introduced in r262893 (GCC 10). A trivial test case is:
$ cat a.c && gcc -O2 -S -Wall a.c
int f (long i)
{
const char *p = "123";
p += i;
return p[-1];
}
a.c: In function ‘f’:
a.c:5:11: warning: array subscript -1 is outside array bounds of ‘char[4]’
[-Warray-bounds]
5 | return p[-1];
| ~^~~~
This same thing is handled correctly elsewhere (e.h., -Wstringop_overflow) so
the ideal fix is to replace the warning code with the new pointer_query class.