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.
  • [Bug c++/102488] New: ICE with ... luc.briand35 at gmail dot com via Gcc-bugs

Reply via email to