public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-103825-4-a1ddiGMJaH@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103825-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103825

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:22510e4a68aa9ca850db34ae62c21c58442d8ab3

commit r13-8560-g22510e4a68aa9ca850db34ae62c21c58442d8ab3
Author: Marek Polacek <polacek@redhat.com>
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 <unnamed-signed:4>.  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)

  parent reply	other threads:[~2024-04-02 18:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-25  0:26 [Bug c++/103825] New: [12 Regression] " blubban at gmail dot com
2021-12-25  0:56 ` [Bug c++/103825] " pinskia at gcc dot gnu.org
2024-03-24 22:55 ` pinskia at gcc dot gnu.org
2024-03-26 15:48 ` mpolacek at gcc dot gnu.org
2024-04-02 18:19 ` cvs-commit at gcc dot gnu.org
2024-04-02 18:26 ` cvs-commit at gcc dot gnu.org [this message]
2024-04-02 18:27 ` mpolacek at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103825-4-a1ddiGMJaH@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).