https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102697
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|[Diagnostics] overflow |[12 Regression] overflow |warning missing after O2 |warning missing after -O2 |vectorization. |vectorization Last reconfirmed| |2021-10-12 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- Confirmed as a false negative and a GCC 12 regression. The expected warning is based on the assumption that an unknown offset to a subobject is non-negative. This assumption is supported by the constraint that pointer arithmetic must be confined to the [sub]object the pointer points to. I.e., it's not valid to form a pointer to one subobject by adding an offset to a pointer to another [sub]object (even within the same object). The same constraint is enforced by -Warray-bounds. The missing -Wstringop-overflow is due to the hack mentioned in the following discussion: https://gcc.gnu.org/pipermail/gcc-patches/2021-September/580172.html The warning is issued from the strlen pass which runs at -O2 and above. It's still issued when -fno-tree-vectorized is specified but should be issued even with vectorization, and ideally at all optimization levels, including -O0.