https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118671
Bug ID: 118671
Summary: [15 regression] ICE in
output_constructor_regular_field at, varasm.cc
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: enrico.seiler+gccbugs at outlook dot com
Target Milestone: ---
The following results in an ICE:
```
#include <optional>
#include <vector>
std::vector<std::optional<int>> a{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
```
Reduced version without includes:
```
namespace std {
template <typename> struct initializer_list {
private:
int *_M_array;
unsigned long _M_len;
};
struct in_place_t {} in_place;
struct optional {
constexpr optional(int __t) : optional(in_place, __t) {}
template <typename... _Args>
constexpr optional(in_place_t, _Args... __args) : _M_value(__args...) {}
int _M_value;
};
struct vector {
vector(initializer_list<optional>);
};
} // namespace std
std::vector a{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
```
Compiler Explorer: https://godbolt.org/z/Eja9To1nP
test.cpp:24:74: internal compiler error: in output_constructor_regular_field,
at varasm.cc:5800
24 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1};
|
^
0x28bba41 internal_error(char const*, ...)
diagnostic-global-context.cc:517
0xab3e27 fancy_abort(char const*, int, char const*)
diagnostic.cc:1722
0x9d71b6 output_constructor_regular_field
varasm.cc:5800
0x9d71b6 output_constructor
varasm.cc:6117
0x181c6c5 assemble_variable_contents
varasm.cc:2440
0x18224ad assemble_variable(tree_node*, int, int, int)
varasm.cc:2619
0x1826b89 varpool_node::assemble_decl()
varpool.cc:596
0xefab33 output_in_order
cgraphunit.cc:2209
0xefab33 symbol_table::compile()
cgraphunit.cc:2415
0xefdb27 symbol_table::compile()
cgraphunit.cc:2329
0xefdb27 symbol_table::finalize_compilation_unit()
cgraphunit.cc:2603
I have not bisected, but I can point to a range:
Last known working:
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=e9bd9d42dddd7a9b1c080426b0b16d3704673cbf
First known fail:
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=06b78732f7ce424ab7d8c619f1ea90936fedff51