Landing: 94843e8b8a47
Project / Subsystem
gcc / c++
Date
2026-08-06
Author
Jakub Jelinek
Commit
94843e8b8a47e9a4972b73637578dac12fe1ade7
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- c++
- patch_id
- —
- commit_hash
- 94843e8b8a47e9a4972b73637578dac12fe1ade7
- source_type
- github
- headline
- Constexpr `break` in expansion statements corrected.
- tldr
- Fixes `constexpr` evaluation to correctly handle `break` statements within expansion statements.
- author
- Jakub Jelinek
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • c++
- • constexpr
- • compiler bug
- • control flow
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-08-06T00:00:00.000Z
This commit resolves an issue in constexpr evaluation where break statements within expansion statements were mishandled. The compiler incorrectly processed these breaks, leading to incorrect constant evaluation results or failures, such as misinterpreting a break as a return or causing outer loops to terminate prematurely. The fix involves wrapping the instantiated bodies of expansion statements in an artificial do...while(0) loop, ensuring that break statements correctly target the intended loop scope within the constexpr context.