GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libstdc++

Libstdc++: Generator avoids ill-formed nested types

The libstdc++ generator now correctly handles nested types by changing its second template parameter to `void`, resolving a long-standing issue with ill-formed…

The generator::yield_value in libstdc++ has been updated to use void as its second template parameter instead of range_value_t<R>. This change addresses a bug (LWG 4119) that caused ill-formed code when dealing with nested generators. The fix ensures that the library correctly handles such scenarios, preventing compilation errors for users.

In Details

The std::generator component within libstdc++ provides C++23 coroutine-based generator functionality. This commit specifically addresses an issue within the generator::yield_value associated with LWG 4119, where incorrect template parameter instantiation could lead to ill-formed types during compilation. The fix changes the second template parameter from range_value_t<R> to void, impacting how the generator's internal coroutine frame handles yielded values and their types, particularly in nested generator contexts. This refinement ensures type correctness and consistency within the…

For Context

In C++, a 'generator' is a special kind of function that can pause its execution and return a value, then later resume from where it left off. This is very useful for creating sequences of values on-the-fly without needing to store them all in memory at once. The C++ standard library includes a feature called std::generator to help you write these. This commit fixes a problem related to how these generators handle complex types, specifically when one generator is nested inside another. Previously, the compiler could get confused about the types being passed around, leading to errors. The change simplifies how the generator tracks these types by using a generic 'void' placeholder in a specific internal operation, ensuring that even complex nested generators can be compiled and used correctly without breaking your code.

Filed Under: libstdc++c++23generatorbugfixtemplate