SUNDAY, APRIL 19, 2026 GCC DIGEST · OPEN-SOURCE SYSTEMS DAILY VOL. 1 · NO. 109
Late Edition · APRIL 19, 2026 · VOL. 1 · NO. 109
The GCC Digest
— A Daily Record of the GNU Compiler Collection —
libstdc++ Impact 6 / 10

Libstdc++: Fix constantness of engaged -> disengaged std::optional.

Clearing a `std::optional` in C++23 now maintains constant expression requirements, fixing a compile-time error.

When a std::optional containing a value is cleared, the destructor of the contained value is invoked, potentially leaving the union without an active member during constant evaluation. This violates constant expression requirements, diagnosed by Clang and recent GCC versions. This patch activates a dummy union member after destroying the value to ensure the union always has an active member and uses std::construct_at to avoid a front-end bug.

Filed Under: libstdc++constexproptionalC++23