Landing: efb9667e2fb8
Project / Subsystem
gcc / c++
Date
2026-05-14
Author
Marek Polacek
Commit
efb9667e2fb81dc0dd4dab25a84756c040bc3506
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- c++
- patch_id
- —
- commit_hash
- efb9667e2fb81dc0dd4dab25a84756c040bc3506
- source_type
- github
- headline
- c++: capture of reference to global in template
- tldr
- Fixes a bug in C++ that caused a crash when capturing a reference to a global variable in a template lambda.
- author
- Marek Polacek
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • c++
- • lambda
- • template
- • bugfix
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-05-14T00:00:00.000Z
This commit fixes a bug that caused GCC to crash when a lambda expression inside a template captures a reference to a global variable. The issue arose because the compiler failed to properly evaluate the reference as a constant within the template context. The fix defers the error checking to instantiation time when the type dependencies are resolved, preventing the crash and ensuring correct code generation.