From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0D76E38582BD; Fri, 15 Dec 2023 13:52:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0D76E38582BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1702648350; bh=jjHMt2VYSBMiAjTisdxNMyli0w0NJTXfmhUTkXl7Tqc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mO5N477dc1+ZgxQ0iptHStgSLSCDUn1gLpRwN+OPtKjIuNPKmf/OWtjxemafraCd/ /UZ/yHpPnNpKM8xGoHlgU9SqtxH7IhQgR2b37FjqnRBPqVFmkD4Tpj0t7TIp0F7oQG oPUmNiqNz+/EkJt4uCh6N9IRO7Xg83QMnFjZYtbw= From: "nathanieloshead at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113031] [14 Regression] ICE in cxx_fold_indirect_ref_1 starting with r14-6508 Date: Fri, 15 Dec 2023 13:52:29 +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: 14.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: nathanieloshead at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113031 --- Comment #2 from Nathaniel Shead --- Reduced to: template class variant; template auto __variant_cast(_Tp __rhs) { return static_cast&&>(__rh= s); } template struct _Move_assign_base : _Types { void operator=3D(_Move_assign_base __rhs) { __variant_cast<_Types>(__rhs)= ; } }; template struct variant : _Move_assign_base<_Types> { void emplace() { variant __tmp; *this =3D __tmp; } }; struct _Undefined_class { struct _Nocopy_types { void (_Undefined_class::*_M_member_pointer)(); }; struct function : _Nocopy_types { struct optional { void test03() { variant v; v.emplace(); } }; }; }; The following patch seems to fix the immediate problem (but not yet fully regtested): diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index e1b2d27fc36..051f73fb73f 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -5709,7 +5709,8 @@ cxx_fold_indirect_ref_1 (const constexpr_ctx *ctx, location_t loc, tree type, } /* Handle conversion to "as base" type. */ - if (CLASSTYPE_AS_BASE (optype) =3D=3D type) + if (CLASS_TYPE_P (optype) + && CLASSTYPE_AS_BASE (optype) =3D=3D type) return op; /* Handle conversion to an empty base class, which is represented wi= th a=