[Bug tree-optimization/107699] False positive -Warray-bounds, non-existent offset reported by GCC

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Nov 16 13:34:08 GMT 2022


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-11-16
                 CC|                            |msebor at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
It diagnoses

if (&MEM <int[3]> [(void *)&data + 64B] != __i_32)

and the code is confused about the <int[3]> type and the address-taken
special allowing taking the address of one after the array.  All the
second-guessing whats the "array access" performed here (none!) is wrong.

If the address is inside or one after the object then it's OK.

Here we guess an element size of 12, visible by

warning: array subscript 16 is outside array bounds of 'std::array<int, 3> [1]'

but no idea where the [1] comes from.  The code might try to match
some useful cases but it should give up in a more forgiving way when it
gets totally wrong in cases like this.


More information about the Gcc-bugs mailing list