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
A default template argument of a nested generic lambda could be rejected when a
pack expansion involving an enclosing pack was incorrectly treated as empty
before the lambda's template arguments were available. Such defaults now
remain dependent until instantiation. For example, with --c++20 -tused:
Fixed a C++20 compiler error affecting default template arguments in nested generic lambdas that reference parameter packs. These defaults now remain dependent until the relevant arguments are available.
Tests
Added regression coverage for empty and nonempty packs, different pack ordering, and defaults that are not instantiated.
No actionable comments were generated in the recent review.
Walkthrough
The compiler now checks whether referenced template parameter packs have corresponding arguments before enabling expansion in a generic-lambda instantiation context. C++20 regression tests cover nested lambda template defaults involving inner and outer packs.
Changes: Nested lambda template defaults
Layer / File(s)
Summary
Pack binding check src/scope_stk.c
The compiler checks referenced packs against current and enclosing template arguments before enabling expansion in a generic-lambda instantiation context.
The C++20 regression test covers defaults combining inner and outer packs, including empty packs, both pack orderings, and an uninstantiated default. Four test commands and a pending-change note are added.
edgcpp/compiler#492: Both PRs change pack-expansion handling in src/scope_stk.c for nested generic lambdas and address related false errors.
Suggested labels:bug
Suggested reviewers:daveedvdv-nvidia
Merge Risk: Minimal · up to d942a
This change keeps default template arguments in nested generic lambdas dependent until the lambda is instantiated, which removes a spurious array-bound error. No concrete defect was established in review. The only remaining question is a narrow edge case that has not been shown to be reachable, and regression tests cover the reported scenario.
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 main change: pack expansions in nested generic-lambda template default arguments, tied to GH #506. The raw summary and objectives confirm the change keeps such defaults dependent u…
Linked Issues check
Issue #506 requires that the reproducer compile with --c++20 -tused without the spurious array-bound error. The premature expansion comes from is_pack_instantiation_context in src/scope_stk.c. I…
Out of Scope Changes check
All changes connect to #506. The has_unbound_template_pack helper and the modified branch in src/scope_stk.c implement the fix. The src/pending_changes/gh-506.txt entry documents the fix. The `t…
Full details: Title check
Explanation
The title names the main change: pack expansions in nested generic-lambda template default arguments, tied to GH #506. The raw summary and objectives confirm the change keeps such defaults dependent until instantiation, so the title matches the changeset. The title uses a technical term and a bracketed issue reference, but it is specific and readable.
Full details: Linked Issues check
Explanation
Issue #506 requires that the reproducer compile with --c++20 -tused without the spurious array-bound error. The premature expansion comes from is_pack_instantiation_context in src/scope_stk.c. In the generic-lambda-in-real-instantiation branch, the previous code returned TRUE unconditionally when the expansion used enclosing packs. The head now returns !has_unbound_template_pack(pedp). The new helper returns TRUE when any referenced template-parameter pack (here the nested lambda's Js) has no argument available. For the reproducer, Js is unbound during the enclosing instantiation, so the expansion stays dependent until the lambda's template arguments exist. The added test tests/tests/regressions/gh-506.sft.cpp covers the reproducer shape in uninstantiated_template_parameter_default and related cases, and the .rto fixtures run it under -tused. Compliance rests on code reading. I did not run the compiler or the tests.
Full details: Out of Scope Changes check
Explanation
All changes connect to #506. The has_unbound_template_pack helper and the modified branch in src/scope_stk.c implement the fix. The src/pending_changes/gh-506.txt entry documents the fix. The tests/tests/regressions/gh-506.sft.cpp file and the .rto fixtures add regression coverage for the fix. The helper's doc comment and the updated comment in is_pack_instantiation_context are part of the same change. No unrelated functional change appears in the reviewed diff.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
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; 3 remain after this review.
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 #506
A default template argument of a nested generic lambda could be rejected when a
pack expansion involving an enclosing pack was incorrectly treated as empty
before the lambda's template arguments were available. Such defaults now
remain dependent until instantiation. For example, with
--c++20 -tused:Summary by CodeRabbit