https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114977
Bug ID: 114977
Summary: C++20 parenthesized aggregate initialization
copy-inits from {} instead of value-init
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mital at mitalashok dot co.uk
Target Milestone: ---
When implementing <https://wg21.link/P0960R3>, unlike when initializing with
aggregate initialization where each element that is not explicitly initialized
is initialized from `{}` (<https://wg21.link/dcl.init.aggr#5.2>), when
direct-initializing they should be value-initialized
(<https://wg21.link/dcl.init.general#16.6.2.2.sentence-6> for aggregate
classes, <https://wg21.link/dcl.init.general#16.5.sentence-7>).
It seems like GCC initializes from `{}` anyways, as seen by this compiling
<https://godbolt.org/z/T3r54Wxnc>:
#include <initializer_list>
struct A {
A(std::initializer_list<void*>);
};
A a[3]({}, {}); // a[2] should be value-initialized and fail
struct B {
int i;
A a;
};
B b(1); // b.a should be value-initialized and fail