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

Reject user-defined specializations for coroutine_handle

User-defined specializations of `std::coroutine_handle` are now ill-formed, improving quality of implementation for coroutines.

The C++ standard library now rejects user-defined specializations of std::coroutine_handle. This change aligns with the C++20 standard’s coroutines enhancements, which disallow such specializations, and provides a diagnostic when they are attempted.

In Details

The std::coroutine_handle template in libstdc++ is now decorated with [[_Clang::__no_specializations]]. This attribute, introduced as part of the coroutines TS merge into C++20, prevents users from specializing the coroutine_handle template. This is a quality-of-implementation (QoI) improvement, ensuring correct usage of coroutine facilities.

For Context
coroutine_handle
A C++ type that provides access to the state and execution of a coroutine.
specialization
In C++, a specific version of a class or function template created for a particular set of template arguments.
ill-formed
A programming construct that violates the rules of the C++ language, meaning it cannot be compiled, and may or may not produce a diagnostic message depending on the standard's requirements.
C++20
A major revision of the C++ programming language standard, introducing features like coroutines, concepts, and modules.
Filed Under: libstdc++coroutinesstandard compliance