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

            Bug ID: 108417
           Summary: [ICE] Crash on aggregate initialization of base class
           Product: gcc
           Version: 10.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m.cencora at gmail dot com
  Target Milestone: ---

Code below compiled on any gcc<11 crashes with following output:
during RTL pass: expand
<source>: In function 'Derived ICE_createDerived()':
<source>:37:5: internal compiler error: in assign_temp, at function.c:984
   37 |     };
      |     ^


FWIW it doesn't crash if field 'f3' is removed.

g++ -std=c++17

struct NonTrivial
{
    NonTrivial() = default;
    NonTrivial(const NonTrivial&);
    NonTrivial& operator=(const NonTrivial&);

    char* ptr = nullptr;
};

struct Base
{
   int f1;
   NonTrivial f2;
   int f3;
};

struct Derived : Base
{
   int f4;
};

Derived createDerivedOk()
{
    return Derived{
        Base{},
        0
    };
}

Base createBase();

Derived ICE_createDerived()
{
    return Derived{
        createBase(),
        0
    };
}

Reply via email to