public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "luc.briand35 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/102488] New: ICE with default constexpr operator== on class with bitfield
Date: Sun, 26 Sep 2021 10:34:39 +0000	[thread overview]
Message-ID: <bug-102488-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 102488
           Summary: ICE with default constexpr operator== on class with
                    bitfield
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luc.briand35 at gmail dot com
  Target Milestone: ---

Hello,

The following code causes an ICE, the culprit being the constexpr operator==.
This only happens on the trunk version (12.0) of gcc.
When the bitfield is smaller than 8 bits, there is no crash.

Godbolt link: https://gcc.godbolt.org/z/eh57da3cE


struct A 
{
    unsigned int a : 8; /* no crash for sizes from 1 to 7 and 32 */

    constexpr bool operator==(const A&) const = default;
};


int main()
{
    A a{}, b{};

    return a == b;
}


Full error message (command: "gcc -c ./test_bug.cpp -std=c++2a"):


./test_bug.cpp: In member function ‘constexpr bool A::operator==(const A&)
const’:
./test_bug.cpp:7:20: error: type mismatch in ‘component_ref’
    7 |     constexpr bool operator==(const A&) const = default;
      |                    ^~~~~~~~
unsigned int

unsigned char

_1 = this->a;
./test_bug.cpp:7:20: error: type mismatch in ‘component_ref’
unsigned int

unsigned char

_2 = D.2080->a;
./test_bug.cpp:7:20: internal compiler error: ‘verify_gimple’ failed
0x100bd2d verify_gimple_in_seq(gimple*)
        ../../gcc-trunk/gcc/tree-cfg.c:5097
0xd40216 gimplify_body(tree_node*, bool)
        ../../gcc-trunk/gcc/gimplify.c:14876
0xd403f3 gimplify_function_tree(tree_node*)
        ../../gcc-trunk/gcc/gimplify.c:14966
0xb88907 cgraph_node::analyze()
        ../../gcc-trunk/gcc/cgraphunit.c:669
0xb8b44f analyze_functions
        ../../gcc-trunk/gcc/cgraphunit.c:1210
0xb8c032 symbol_table::finalize_compilation_unit()
        ../../gcc-trunk/gcc/cgraphunit.c:2956
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

             reply	other threads:[~2021-09-26 10:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-26 10:34 luc.briand35 at gmail dot com [this message]
2021-09-27 11:37 ` [Bug c++/102488] " pinskia 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-102488-4@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).