You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix crash in alias template CTAD with member template call in constructor noexcept [GH #532] - #531
make_operand_for_rescanned_identifier substituted its arguments and then passed the already substituted list to scan_identifier, which substituted them again. This could lead to errors and in the #532 reproducer, a segfault. This fix avoids substituting the explicit template arguments of a dependent member template-id twice.
Summary by CodeRabbit
Bug Fixes
Fixed a compiler crash when C++20 class template argument deduction uses an alias template and a constructor’s noexcept specification calls a member function template with the constructor’s parameter pack.
Tests
Added regression coverage for this scenario across multiple compiler configurations.
gwllx
changed the title
Fix crash in alias template CTAD with member template call in constructor noexcept
Fix crash in alias template CTAD with member template call in constructor noexcept [GH #522]
Nov 13, 2026
No actionable comments were generated in the recent review.
Walkthrough
The compiler now stores a separately rebuilt template argument list for dependent template references, leaving the explicit list available for later substitution by scan_identifier. A C++20 regression case and compiler-specific fixtures cover alias-template CTAD with a constructor noexcept member-template call.
The dependent template reference now uses a separately rebuilt argument list. The original explicit list remains available for substitution by scan_identifier.
The C++20 regression test and compiler-specific fixtures cover the reported alias-template CTAD scenario. The pending-changes note includes its description and reproducer.
This change fixes a compiler crash by avoiding duplicate template argument substitution, and a regression test covers the reported case. No outstanding risks were identified, so it looks ready to merge.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the crash fix, the affected feature (alias template CTAD), the triggering construct (member template call in constructor noexcept), and the issue number. The raw summary describes a ch…
Linked Issues check
Issue #532 requires that the alias-template CTAD reproducer compile under cpfe --c++20 without a segfault. The issue attributes the crash to double substitution of the explicit template arguments of…
Out of Scope Changes check
All changed files relate to #532. src/expr.c contains the substitution fix. src/pending_changes/gh-532-alias-ctad-noexcept-template-call.txt documents the fix. tests/tests/regressions/gh-532.sft.cpp a…
Full details: Title check
Explanation
The title names the crash fix, the affected feature (alias template CTAD), the triggering construct (member template call in constructor noexcept), and the issue number. The raw summary describes a change to src/expr.c that stops explicit template arguments from being substituted twice, which matches the crash fix in the title. The PR objectives describe the same duplicate-substitution bug and link it to issue #532. The title is specific and accurate, so it passes.
Full details: Linked Issues check
Explanation
Issue #532 requires that the alias-template CTAD reproducer compile under cpfe --c++20 without a segfault. The issue attributes the crash to double substitution of the explicit template arguments of a dependent member template-id, which leads to an out-of-range index in get_template_arg_by_list_pos. The diff in src/expr.c (whole PR, merge base to head) changes the dependent non-type template parameter branch of make_operand_for_rescanned_identifier. The expression copy_template_arg_list_with_substitution_rebuilding_arg_operands now writes its result to a new local, subst_templ_arg_list. The unsubstituted expl_templ_arg_list is no longer replaced, so scan_identifier performs the only substitution. The template-reference constant's arg_list takes the rebuilt list. This addresses the root cause that #532 describes. The PR also adds a regression test, tests/tests/regressions/gh-532.sft.cpp, with the reproducer and matching .rto fixtures. I did not execute the compiler, so the absence of the segfault rests on source reading and the added test, not on a run result.
Full details: Out of Scope Changes check
Explanation
All changed files relate to #532. src/expr.c contains the substitution fix. src/pending_changes/gh-532-alias-ctad-noexcept-template-call.txt documents the fix. tests/tests/regressions/gh-532.sft.cpp and the .rto/default.N.1.txt fixtures add the regression test and its command variants. The src/expr.c hunk is limited to the affected branch and its comment. No unrelated behavior change appears in the reviewed hunk. The whole-PR diff of other source files was not inspected in full, but the change summary lists no other source changes.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
gwllx
changed the title
Fix crash in alias template CTAD with member template call in constructor noexcept [GH #522]
Fix crash in alias template CTAD with member template call in constructor noexcept [GH #532]
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #532.
make_operand_for_rescanned_identifiersubstituted its arguments and then passed the already substituted list toscan_identifier, which substituted them again. This could lead to errors and in the #532 reproducer, a segfault. This fix avoids substituting the explicit template arguments of a dependent member template-id twice.Summary by CodeRabbit
noexceptspecification calls a member function template with the constructor’s parameter pack.