Landing: eccc490c21fc
Project / Subsystem
gcc / libstdc++
Date
2026-09-02
Author
Jakub Jelinek
Commit
eccc490c21fc7c9dadf8d13566963bce151c902d
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- libstdc++
- patch_id
- —
- commit_hash
- eccc490c21fc7c9dadf8d13566963bce151c902d
- source_type
- github
- headline
- Implement C++26 P2641R4 - Checking if a union alternative is active
- tldr
- Implements C++26 P2641R4 in libstdc++ for checking union active members at compile time using `__builtin_is_within_lifetime`.
- author
- Jakub Jelinek
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • gcc
- • libstdc++
- • C++26
- • compile time
- • type safety
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-09-02T00:00:00.000Z
This patch implements the C++26 feature P2641R4, allowing compile-time checks for which member of a union is currently active. It introduces a builtin function that returns true if a given pointer points to an active union member, with specific handling for constant expressions and lifetime rules. This aligns GCC’s libstdc++ with Clang’s implementation of the paper, enhancing type safety and enabling more robust compile-time evaluations.