[Bug tree-optimization/106901] [13 Regression] False positive -Warray-bounds with -O2 or higher?

carlosgalvezp at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Oct 11 12:28:33 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106901

--- Comment #7 from Carlos Galvez <carlosgalvezp at gmail dot com> ---
I understand the reasoning, but the loop _can_ executed in other cases where
the function is called with different arguments:

bar(vec, 5, 5);  // Warray-bounds, loop not executed, no runtime OOB.
bar(vec, 5, 4);  // No Warray-bounds, loop executed,  no runtime OOB.

There is no OOB access in either case, so the compiler is incorrect in claiming
there is one. If there were, the OOB access would show up in Valgrind or ASan,
which is not the case.

Please note that the presence of False Positives in basic compiler warnings
like Wall or Wextra damages the credibility of compiler warnings. Warnings that
may have FPs should go in a different category, or as part of a separate tool,
like a static analyzer.


More information about the Gcc-bugs mailing list