From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 936D4393A433; Thu, 8 Jul 2021 15:47:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 936D4393A433 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [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] Date: Thu, 08 Jul 2021 15:47:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: bootstrap X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: msebor at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jul 2021 15:47:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101374 --- Comment #9 from Martin Sebor --- 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; ... [local count: 1073741824]: _7 =3D &this_1(D)->D.2395; <<< varpool_node::symtab_node subob= ject _11 =3D is_a (_7); if (_11 !=3D 0) goto ; [71.00%] else goto ; [29.00%] [local count: 311385128]: [local count: 1073741824]: # _12 =3D PHI <_7(2), 0B(3)> <<< _12 size is (at most) 4 _15 =3D 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, ...) (w= ith Object Size Type 1) respects subobject boundaries and so doesn't consider t= hat _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 red= uced test case. Let me see if it also fixes the rest of the problems.=