From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 974D33886C65; Thu, 8 Jul 2021 09:22:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 974D33886C65 From: "rguenth 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 09:22:14 +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: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned 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 09:22:15 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101374 --- Comment #3 from Richard Biener --- The following fails with -O2 -Wall -Werror after but not before the rev. - = not sure if the reduction is otherwise sensible. template struct reinterpret_is_a_helper { template static T cast(U p) { return T(p); } }; template bool is_a(U); template T dyn_cast(U p) { if (is_a(p)) return reinterpret_is_a_helper::cast(p); return 0; } enum tree_node_structure_enum { TS_DECL_COMMON }; void contains_struct_check(int, tree_node_structure_enum, const char *, int, const char *); enum availability { AVAIL_NOT_AVAILABLE, AVAIL_AVAILABLE }; struct symtab_node { symtab_node *ultimate_alias_target(); unsigned definition : 1; unsigned in_other_partition : 1; }; struct varpool_node : symtab_node { availability get_availability(); varpool_node *ultimate_alias_target(symtab_node *); unsigned : 1; }; inline symtab_node *symtab_node::ultimate_alias_target() { dyn_cast(this)->get_availability(); dyn_cast(this)->get_availability(); return 0; } inline varpool_node *varpool_node::ultimate_alias_target(symtab_node *) { symtab_node __trans_tmp_1 =3D *symtab_node::ultimate_alias_target(); varpool_node *n =3D dyn_cast(&__trans_tmp_1); return n; } availability varpool_node::get_availability() { symtab_node ref; if (definition && in_other_partition) return AVAIL_NOT_AVAILABLE; ultimate_alias_target(&ref); contains_struct_check(0, TS_DECL_COMMON, "", 5, __FUNCTION__); return AVAIL_AVAILABLE; } > /tmp/obj2/prev-gcc/cc1plus -quiet varpool.ii -O2 -Wall -Werror=20 In member function 'availability varpool_node::get_availability()', inlined from 'symtab_node* symtab_node::ultimate_alias_target()' at varpool.ii:25:51, inlined from 'varpool_node* varpool_node::ultimate_alias_target(symtab_node*)' at varpool.ii:30:66, inlined from 'availability varpool_node::_ZN12varpool_node16get_availabilityEv.part.0()' at varpool.ii:38:24: varpool.ii:36:18: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=3Darray-bounds] 36 | if (definition && in_other_partition) | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ varpool.ii: In member function 'availability varpool_node::_ZN12varpool_node16get_availabilityEv.part.0()': varpool.ii:19:8: note: object 'varpool_node::' of size 4 19 | struct varpool_node : symtab_node { | ^~~~~~~~~~~~ In member function 'availability varpool_node::get_availability()', inlined from 'symtab_node* symtab_node::ultimate_alias_target()' at varpool.ii:26:51, inlined from 'varpool_node* varpool_node::ultimate_alias_target(symtab_node*)' at varpool.ii:30:66, inlined from 'availability varpool_node::_ZN12varpool_node16get_availabilityEv.part.0()' at varpool.ii:38:24: varpool.ii:36:18: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=3Darray-bounds] 36 | if (definition && in_other_partition) | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ varpool.ii: In member function 'availability varpool_node::_ZN12varpool_node16get_availabilityEv.part.0()': varpool.ii:19:8: note: object 'varpool_node::' of size 4 19 | struct varpool_node : symtab_node { | ^~~~~~~~~~~~ cc1plus: all warnings being treated as errors=