gen-c: a slice field takes the compound literal, except in a return - #3493
Merged
Conversation
Closes #3492 Five passes in a row found their subject by SPLITTING a class rather than by picking the biggest number. This one ran that instrument again and then put it in the tool: `c_error_classes.py` prints diagnostics, distinct lines and the RATIO together. diags lines d/l class 2959 2224 1.33 use of undeclared identifier 1995 1960 1.02 call to undeclared function 750 668 1.12 expected expression 590 590 1.00 cannot use '__auto_type' with initializer list 199 199 1.00 incompatible integer to pointer conversion <- this 140 140 1.00 type name requires a specifier or qualifier A ratio of 1.00 means no cascade -- every diagnostic is its own site. Ranking by diagnostics alone had left `redefinition` in eighth place for six passes at exactly 1.00, and it was the cleanest population there. THE SUBJECT: `(WeightBank){ .data = { 1, 2, 3, 4 } }`. The field is declared `[]i32`, which lowers to `int32_t*`, and a brace list is not a pointer. 199 sites in 9 files. The repair is the compound literal a call argument already gets, with the element type taken from the FIELD's declaration through the same helper. THE POSITION HAD TO BE MEASURED BEFORE THE CODE WAS WRITTEN. A compound literal at block scope dies with its block: a local declaration 197 the literal outlives the statement inside a `return` 4 the address of a local (#3445) an assignment 1 So a flag records whether a `return` operand is being emitted -- and THIS BACKEND HAS TWO RETURN ARMS, the statement and the expression. The first version set the flag in the expression arm only, and the returned struct literal took the cast anyway: the same "all the call sites" defect the guard exists to prevent, one level up. A test covers the nested case. MEASURED, whole corpus, -ferror-limit=0: errors 11 401 -> 11 191 (-210) the class 199 -> 6 files better/worse 7 / 1 igla_race_bram_weights 209 -> 112 igla_race_ternary_inference 219 -> 123 THE ONE WORSE FILE IS UNMASKING, CHECKED RATHER THAN ASSUMED. igla_race_backend 106 -> 107: one `initializing ... with an expression of incompatible type` disappeared because `m` now has a valid type, and two appeared on a later line where `out.assigns.len()` became visible -- both of already-known families (`->` and `len`). Tests: 5 new, full suite 3548 passed 0 failed. Four mutants, all killed, including the one that drops the statement-return flag. 8 stale seals refreshed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
gHashTag
enabled auto-merge (squash)
September 8, 2026 12:38
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
Contributor
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
gen-c: a slice field takes the compound literal, except in a return
Closes #3492
Five passes in a row found their subject by SPLITTING a class rather
than by picking the biggest number. This one ran that instrument again
and then put it in the tool:
c_error_classes.pyprints diagnostics,distinct lines and the RATIO together.
diags lines d/l class
2959 2224 1.33 use of undeclared identifier
1995 1960 1.02 call to undeclared function
750 668 1.12 expected expression
590 590 1.00 cannot use '__auto_type' with initializer list
199 199 1.00 incompatible integer to pointer conversion <- this
140 140 1.00 type name requires a specifier or qualifier
A ratio of 1.00 means no cascade -- every diagnostic is its own site.
Ranking by diagnostics alone had left
redefinitionin eighth place forsix passes at exactly 1.00, and it was the cleanest population there.
THE SUBJECT:
(WeightBank){ .data = { 1, 2, 3, 4 } }. The field isdeclared
[]i32, which lowers toint32_t*, and a brace list is not apointer. 199 sites in 9 files. The repair is the compound literal a call
argument already gets, with the element type taken from the FIELD's
declaration through the same helper.
THE POSITION HAD TO BE MEASURED BEFORE THE CODE WAS WRITTEN. A compound
literal at block scope dies with its block:
a local declaration 197 the literal outlives the statement
inside a
return4 the address of a local (#3445)an assignment 1
So a flag records whether a
returnoperand is being emitted -- andTHIS BACKEND HAS TWO RETURN ARMS, the statement and the expression. The
first version set the flag in the expression arm only, and the returned
struct literal took the cast anyway: the same "all the call sites"
defect the guard exists to prevent, one level up. A test covers the
nested case.
MEASURED, whole corpus, -ferror-limit=0:
errors 11 401 -> 11 191 (-210)
the class 199 -> 6
files better/worse 7 / 1
igla_race_bram_weights 209 -> 112
igla_race_ternary_inference 219 -> 123
THE ONE WORSE FILE IS UNMASKING, CHECKED RATHER THAN ASSUMED.
igla_race_backend 106 -> 107: one
initializing ... with an expression of incompatible typedisappeared becausemnow has a valid type, andtwo appeared on a later line where
out.assigns.len()became visible --both of already-known families (
->andlen).Tests: 5 new, full suite 3548 passed 0 failed. Four mutants, all killed,
including the one that drops the statement-return flag. 8 stale seals
refreshed.
🤖 Generated with Claude Code