https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109071
--- Comment #11 from qinzhao at gcc dot gnu.org --- please see discussion at: https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651482.html A summary of the discussion: 1. The current warning is correct, which catches a potential source code error that should be fixed in the source code level; 2. The best way to fix the source code level error is: make the routine "warn" a non-return function, and use the attribute __noreturn __ to mark it. 3. Although the warning is correct in theory, the warning message itself is confusing to the end-user since there is information that cannot be connected to the source code directly. 4. It will be a nice improvement to add more information in the warning message to report the location info on where such index value come from, for example: warning: array index always above array bounds events 1: | 3 | if (index >= 4) | (1) when index >= 4 then the end-user will know how such out-of-bound access come from. We also need to clarify in the documentation part on how to fix such warnings in the source code level. 5. In order to implement the above 4, we might need to record the location information to somewhere (in STMT or in Block) during the code duplication phase. more details need to be worked out on this.