[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jul 8 15:47:50 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374
--- Comment #9 from Martin Sebor <msebor at gcc dot gnu.org> ---
For the test case the warning sees this:
int varpool_node::_ZN12varpool_node16get_availabilityEv.part.0 (struct
varpool_node * const this)
{
...
struct symtab_node * _7;
struct varpool_node * _12;
...
<bb 2> [local count: 1073741824]:
_7 = &this_1(D)->D.2395; <<< varpool_node::symtab_node subobject
_11 = is_a<varpool_node*, symtab_node*> (_7);
if (_11 != 0)
goto <bb 4>; [71.00%]
else
goto <bb 3>; [29.00%]
<bb 3> [local count: 311385128]:
<bb 4> [local count: 1073741824]:
# _12 = PHI <_7(2), 0B(3)> <<< _12 size is (at most) 4
_15 = BIT_FIELD_REF <*_12, 8, 0>; <<< -Warray-bounds
The MEM_REF *_12 accesses a varpool_node object with size 8 but _12 points to a
symtab_node subobject with size of just 4. So the warning code works
correctly. It triggers because the call to compute_objsize(..., 1, ...) (with
Object Size Type 1) respects subobject boundaries and so doesn't consider that
_12, or more precisely _7, points to a subobject of a larger object. Before
r12-2132 -Warray-bounds did its own slightly more conservative computation
which was roughly equivalent to Object Size Type 0.
Calling compute_objsize(..., 0, ...) instead avoids the warning for the reduced
test case. Let me see if it also fixes the rest of the problems.
More information about the Gcc-bugs
mailing list