GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
c++

Address aggregate initialization issues with designated initializers.

Fixes compiler behavior for aggregate initialization with designated initializers and brace elision.

This commit addresses two issues related to aggregate initialization in C++ with designated initializers. It loosens assertions in the compiler to correctly handle cases where a vector is treated as an aggregate and also fixes a scenario involving designated initializers with brace elision. These changes ensure more robust handling of modern C++ aggregate initialization features, resolving PRs c++/128532 and c++/127516.

In Details

In gcc/cp/decl.cc, the functions reshape_init_r and reshape_init are updated. reshape_init_r now treats a vector as an aggregate, relaxing an assertion. reshape_init is modified to correctly handle designated initializers that use brace elision in conjunction with the old designated initializer extension, addressing issues reported in PRs c++/128532 and c++/127516.

For Context
aggregate initialization
A C++ mechanism for initializing objects of aggregate types (like arrays and structs/classes with no user-declared constructors, etc.) using brace-enclosed lists of values.
designated initializer
A C++ feature that allows specifying which member or element of an aggregate is being initialized, using a dot notation (e.g., .member = value) or an array index notation (e.g., [index] = value).
brace elision
A C++ feature that allows omitting inner braces in aggregate initialization when initializing a sub-aggregate, provided the elements are listed in order.
vector
In this context, likely refers to std::vector or a similar container type that is being treated as an aggregate for initialization purposes.
assertion
A statement embedded in code that checks a condition believed to be true at that point. If the condition is false, an assertion failure typically halts the program, used for debugging and verifying invariants.
Filed Under: c++initializationaggregatedesignated initializer