https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126335
Bug ID: 126335
Summary: Wrong code: trailing default-constructed element of a
static array of class type left uninitialized
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: sberg.fun at gmail dot com
Target Milestone: ---
Starting with
<https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=60335dec4d21b5956afc1e3f1d865fed0b3cfd39>
"c++: simplify condition in check_initializer" towards GCC 17,
```
$ cat test.cc
struct D {};
struct Lit {
constexpr Lit(char const *) {}
D str;
};
auto empty = Lit("");
struct S {
D * p;
constexpr S() { p = &empty.str; }
S(Lit) {}
~S() {}
};
template<Lit L> S operator ""_s() { return L; }
struct M { S a, b; };
static M m[2]{{""_s, ""_s}, {}};
int main() { return m[1].a.p == nullptr; }
```
```
$ g++ test.cc && ./a.out
```
now fails and returns exit code 1 instead of the expected exit code 0.