https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107677
Bug ID: 107677 Summary: -Warray-bounds: unclear what exactly it's meant to detect Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: carlosgalvezp at gmail dot com Target Milestone: --- Hi, I have a hard time understanding -Warray-bounds. The documentation says: "It warns about subscripts to arrays that are always out of bounds" And yet, none of the hits of the warning are caught by sanitizer, nor by valgrind, nor by Clang. So how can it be that they "always" are out of bounds? Surely they should have been caught by some other tool, if it were so obvious? Some of the warnings go away if I "assert" that the subscript index is smaller than the size of the array, even if the assertion is not needed. Is GCC warning about "maybe" out of bounds cases, instead of "real" cases? Lastly, I find the stacktrace very confusing. It simply says "array subscript X is out of bounds". Where does this X come from? Is it real (and if so, where in the code is the number X defined?), or is it "a possibility" that may or may not happen based on runtime input? Thanks!