From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9415D3890424; Fri, 16 Apr 2021 09:04:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9415D3890424 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/100111] [10/11 Regression] `-fno-elide-constructors` with `constexpr` ctors causes ICE in GCC 10.3 Date: Fri, 16 Apr 2021 09:04:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.3.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.4 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: Fri, 16 Apr 2021 09:04:12 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100111 --- Comment #3 from Jakub Jelinek --- The ICE is during ((struct j *) this)->e =3D 0 evaluation and the problem s= eems to be that *valp, which is CONSTRUCTOR for the a variable initializer, is {.h=3D{}} where the type of the inner {} is b rather than j. That invalid CONSTRUCTOR elt seems to have been inserted when cxx_eval_store_expression *(struct b *) this =3D *(const struct b &) (const struct b *) &k; I wonder if the bug isn't in: /* Don't share a CONSTRUCTOR that might be changed later. */ init =3D unshare_constructor (init); if (*valp && TREE_CODE (*valp) =3D=3D CONSTRUCTOR && TREE_CODE (init) =3D=3D CONSTRUCTOR) { /* An outer ctx->ctor might be pointing to *valp, so replace its contents. */ if (!same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (init), TREE_TYPE (*valp))) { /* For initialization of an empty base, the original target will = be *(base*)this, evaluation of which resolves to the object argument, which has the derived type rather than the base type. = In this situation, just evaluate the initializer and return, since there's no actual data to store. */ gcc_assert (is_empty_class (TREE_TYPE (init)) && !lval); return init; } CONSTRUCTOR_ELTS (*valp) =3D CONSTRUCTOR_ELTS (init); TREE_CONSTANT (*valp) =3D TREE_CONSTANT (init); TREE_SIDE_EFFECTS (*valp) =3D TREE_SIDE_EFFECTS (init); CONSTRUCTOR_NO_CLEARING (*valp) =3D CONSTRUCTOR_NO_CLEARING (init); } else *valp =3D init; where we do that if (!same_type_ignoring... check and early out only if *va= lp, but in this case *valp is NULL and so we do the *valp =3D init; , except th= at it is still empty class store with !lval. While TREE_TYPE (*valp) can't be checked obviously, type can.=