Landing: dad7275f7cc5
Project / Subsystem
gcc / c++/templates
Date
2026-09-07
Author
Iain Sandoe
Commit
dad7275f7cc570fe222777285d8e8dbf274bb772
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- c++/templates
- patch_id
- —
- commit_hash
- dad7275f7cc570fe222777285d8e8dbf274bb772
- source_type
- github
- headline
- C++: Fix folding of CONSTRUCTOR in templates to avoid invalid expressions.
- tldr
- C++ template instantiation now correctly avoids folding CONSTRUCTORs that have already been processed, fixing an issue with template expression substitution.
- author
- Iain Sandoe
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • c++
- • templates
- • compiler bug
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-09-07T00:00:00.000Z
This commit addresses a bug in C++ template instantiation where the compiler attempted to re-fold a CONSTRUCTOR expression within a template. This occurred after the Non-Type Template Parameter Declaration (NSDMI) had already been folded, leading to invalid expressions that the template substitution machinery could not handle.
The fix, implemented in typeck2.cc, prevents the folding of CONSTRUCTORs in such scenarios, resolving the issue and ensuring correct template instantiation. A new test case is added to verify the fix.