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
Emit constructor arguments in compound literals. [GH #619] - #616
The C++-generating back end could assert when a compound literal invoked a
constructor and appeared as a temporary, such as in a = b = (S){n, 0};.
The earlier fix for EDGcpfe/19463 handled variable initializers through gen_dynamic_init. The assignment case reached gen_compound_literal
directly through gen_temp_init.
Move constructor emission into gen_compound_literal so both paths use the
same code. Reuse the existing argument generator to preserve default
arguments and emit the correct braces for std::initializer_list
constructors.
Fixed C++ code generation for compound literals that invoke constructors when used as temporary values, including in assignments and initializer-list expressions.
Tests
Added regression coverage for constructor calls, chained assignments, and initializer-list temporaries across supported C++17 modes.
No actionable comments were generated in the recent review.
Walkthrough
The C++ back end now routes compound literals through gen_compound_literal, which emits constructor arguments for constructor initializers. A regression test checks chained assignment and initializer-list construction of temporaries across compiler options.
Changes: Compound literal constructor handling
Layer / File(s)
Summary
Route compound literals through constructor emission src/cp_gen_be.c
gen_compound_literal handles constructor initializer arguments without surrounding parentheses. gen_dynamic_init routes all compound literals through this helper.
Test temporary construction tests/tests/regressions/gh-619-compound-literal-constructor.sft.cpp, tests/tests/regressions/.gh-619-compound-literal-constructor.rto/*, src/pending_changes/gh-619-compound-literal-constructor.txt
The regression test checks chained assignment from an S temporary and member access on a List temporary. Fixtures run the test with multiple compiler options. The release note describes the constructor-temporary case.
This change fixes the code generator's handling of constructor-invoking compound literals used as temporaries, for example in chained assignments. A regression test covers the case. No remaining merge risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "Emit constructor arguments in compound literals. [GH #619]" matches the main change. The raw summary and PR objectives show that gen_compound_literal now emits constructor arguments for con…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check
Explanation
The title "Emit constructor arguments in compound literals. [GH #619]" matches the main change. The raw summary and PR objectives show that gen_compound_literal now emits constructor arguments for constructor-invoking compound literals, including temporaries such as the assignment case. The title is specific and concise. It references GH #619, although the PR objectives say the PR reports fixing #614 and also references #619. This does not make the title misleading.
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; 3 remain after this review.
jakub-labenski
changed the title
Emit constructor arguments in compound literals. [GH #614]
Emit constructor arguments in compound literals. [GH #619]
Nov 27, 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.
The C++-generating back end could assert when a compound literal invoked a
constructor and appeared as a temporary, such as in
a = b = (S){n, 0};.The earlier fix for EDGcpfe/19463 handled variable initializers through
gen_dynamic_init. The assignment case reachedgen_compound_literaldirectly through
gen_temp_init.Move constructor emission into
gen_compound_literalso both paths use thesame code. Reuse the existing argument generator to preserve default
arguments and emit the correct braces for
std::initializer_listconstructors.
Discussion #614.
Issue: #619.
Summary by CodeRabbit