https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102697
Bug ID: 102697 Summary: [Diagnostics] overflow warning missing after O2 vectorization. Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: crazylht at gmail dot com CC: msebor at gcc dot gnu.org Target Milestone: --- Host: x86_64-pc-linux-gnu testcase is from Wstringop-overflow-76.c It looks to me the testcase is not well written since variable i here could be negative value, and d[6] may not overflow. #define MAX(p, q) ((p) > (q) ? (p) : (q)) struct B4_B6 { char b4[4]; char b6[6]; // { dg-message "at offset 6 into destination object 'b6' of size 6" "note" } }; void max_B6_B4 (int i, struct B4_B6 *pb4_b6) { char *p = pb4_b6->b6 + i; char *q = pb4_b6->b4 + i; char *d = MAX (p, q); d[3] = 0; d[4] = 0; d[5] = 0; d[6] = 0; // { dg-warning "writing 1 byte into a region of size 0 " } }