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

            Bug ID: 121445
           Summary: ICE in build_data_member_initialization when compiling
                    constexpr constructor with nested non-literal types
                    (C++23)
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jirehguo at tju dot edu.cn
  Target Milestone: ---

When compiling the following valid code using -std=c++23 flag, the compiler
crashes with an internal compiler error.
Reproducer: https://godbolt.org/z/9c6q7TzzG

Flags: -std=c++23

Code:
```
#include <string>

struct S {
  constexpr S() {
    struct InnerStruct {
      std::string str;
    };

    struct MiddleStruct {
      InnerStruct inner;
    };

    struct OuterStruct {
      MiddleStruct middle;
    };

    OuterStruct outer{};
    outer.middle.inner.str = "";
  }
};
```

Output:
```
<source>: In constructor 'constexpr S::S()':
<source>:19:3: internal compiler error: in build_data_member_initialization, at
cp/constexpr.cc:485
   19 |   }
      |   ^
0x2890715 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x2885fb6 internal_error(char const*, ...)
        ???:0
0xaf7890 fancy_abort(char const*, int, char const*)
        ???:0
0xb785ee maybe_save_constexpr_fundef(tree_node*)
        ???:0
0xbedfe7 finish_function(bool)
        ???:0
0xd27003 c_parse_file()
        ???:0
0xe922c9 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```

Reply via email to