GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libstdc++

libstdc++: Fix value-initialization for _Hashtable_ebo_helper members

libstdc++: Resolves a regression in unordered containers by correctly value-initializing EBO helper members.

A regression in libstdc++‘s unordered containers has been fixed by properly value-initializing members of _Hashtable_ebo_helper. Previously, aggregate initialization with {} was ill-formed when members had explicit default constructors, breaking support for custom hashers, equality predicates, and allocators. This patch uses Type() syntax for value-initialization, ensuring correct initialization of all aggregate members and invocation of default constructors.

In Details

libstdc++: Addresses PR126949 by correcting the initialization of _Hashtable_ebo_helper members in include/bits/hashtable_policy.h. The change modifies members like _M_hash, _M_equal, and _M_alloc to use value initialization (= Type()) within their non-static data member initializers (NSDMI). This resolves an issue where aggregate initialization ({}) with explicit default constructors for these members led to ill-formed code and regressions in custom policy support.

For Context
_Hashtable_ebo_helper
A helper class in libstdc++'s hashtable implementation that utilizes the Empty Base Optimization (EBO) to reduce memory overhead by incorporating policy classes (like hashers, equality, allocators) directly as members instead of base classes.
value-initialization
A form of initialization in C++ that zero-initializes fundamental types, default-initializes class types (calling their default constructor), and initializes other types according to specific rules. It's generally safer and more predictable than default-initialization.
aggregate initialization
A C++ initialization method for aggregates (arrays, structs, classes without user-declared constructors, private/protected members, or base classes). It uses braced lists {} to initialize members in declaration order.
NSDMI
Non-Static Data Member Initializer. A C++ feature allowing data members of a class to be initialized directly at their point of declaration, rather than solely within constructors.
Empty Base Optimization (EBO)
A C++ compiler optimization where an empty base class does not occupy any space in the derived class layout. This is often used for policy classes.
Filed Under: libstdc++unordered_mapbugfixC++