From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E8976385840E; Tue, 2 Apr 2024 18:26:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E8976385840E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712082410; bh=xAyQON+gOVLAM3lCz4NuoGB43XQ0swj4JZ00FcbKvNM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZxnOQMYabQ+S5z/C71P6q6dGyQyVqMwPA94dRQEixZ+GtNs9KYgFi62b5iEtia6Jd 6GVOqI9kjFoH6A+gS7YPgmdy1AfKq8LqlnO42N38fZ1LhCcYE9F1ro3L4syWwHCWtR GoI9anbVgwd0OKhbf5eykbWjx+/3jUI2MlvxnrRk= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103825] ICE on switch on enum class in bitfield Date: Tue, 02 Apr 2024 18:26:50 +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: 12.0 X-Bugzilla-Keywords: ice-checking, ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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=3D103825 --- Comment #5 from GCC Commits --- The releases/gcc-13 branch has been updated by Marek Polacek : https://gcc.gnu.org/g:22510e4a68aa9ca850db34ae62c21c58442d8ab3 commit r13-8560-g22510e4a68aa9ca850db34ae62c21c58442d8ab3 Author: Marek Polacek Date: Fri Mar 29 16:59:37 2024 -0400 c++: ICE with scoped enum in switch condition [PR103825] Here we ICE when gimplifying enum class Type { Pawn }; struct Piece { Type type : 4; }; void foo() { switch (Piece().type) case Type::Pawn:; } because we ended up with TYPE_PRECISION (cond) < TYPE_PRECISION (case). That's because the case expr type here is the unlowered type Type, whereas the conditional's type is the lowered . This is not supposed to happen: see the comment in pop_switch around the is_bitfield_expr_with_lowered_type check. But here we did not revert to the lowered SWITCH_STMT_TYPE, because the conditional contains a TARGET_EXPR, which has side-effects, which means that finish_switch_cond -> maybe_cleanup_point_expr wraps it in a CLEANUP_POINT_EXPR. And is_bitfield_expr_with_lowered_type does not see through those. PR c++/103825 gcc/cp/ChangeLog: * typeck.cc (is_bitfield_expr_with_lowered_type): Handle CLEANUP_POINT_EXPR. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/enum44.C: New test. (cherry picked from commit daa2e7c7ffe49b788357f7f2c9ef1c9b125c1f8c)=