https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106762
--- Comment #5 from qinzhao at gcc dot gnu.org ---
with my work-in-progress patch + -fdiagnostics-explain-harder:
t_106762.c: In function ‘bug’:
t_106762.c:16:2: warning: ‘memset’ offset [0, 7] is out of the bounds [0, 0]
[-Warray-bounds=]
16 | memset(&obj->field1, 0xff, sizeof(obj->field1));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
‘bug’: events 1-2
12 | if (idx < ary->objcnt)
| ^
| |
| (1) when the condition is evaluated to false
......
16 | memset(&obj->field1, 0xff, sizeof(obj->field1));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| (2) out of array bounds here
looks a nice improvement to the diagnostic.