FRIDAY, JULY 10, 2026
libstdc++
libstdc++: Mandate complete type for start_lifetime_as_array.
Ensures `std::start_lifetime_as_array` requires a complete type.
The std::start_lifetime_as_array function in libstdc++ now explicitly requires the template type parameter _Tp to be a complete type. This enforces a requirement from P2679R2, preventing potential issues with incomplete types in lifetime extension operations and adding a static assertion and a new negative test case for verification.
In Details
Implements the final part of P2679R2 by adding a static_assert to std::start_lifetime_as_array to ensure _Tp is a complete type. This prevents undefined behavior or incorrect instantiations when the function is called with incomplete types, complementing the existing check in std::start_lifetime_as.
For Context
- libstdc++
- The C++ standard library implementation used by GCC.
- std::start_lifetime_as_array
- A C++ utility function that grants a new lifetime to an array of objects at a given memory location, useful for type-punning or placement new scenarios.
- complete type
- A type in C++ for which the compiler knows the full size and layout. This is in contrast to an incomplete type, such as a forward-declared class or an array with an unspecified size.
- P2679R2
- A C++ standard proposal (revision 2) focused on fixing issues related to
std::start_lifetime_asandstd::start_lifetime_as_array. - static_assert
- A C++ compile-time assertion that checks a condition and generates a compile-time error if the condition is false. It's used here to enforce type constraints.