verilog: a zero-length array is not a register of usize::MAX bits (Refs #2566) - #2605
Merged
Conversation
`var notebooks : [0]Notebook` is a legal empty list. The packed-array
path computes `total_width = dims[0] * elem_w`, which is 0, and then
`total_width - 1` on a usize is 18446744073709551615 -- emitted as
reg [18446744073709551615:0] notebooks;
at exit 0, past every green gate (#2566). Two sites, the 1-D and the
multi-dimensional branch, clamped the way range_decl clamps: a one-bit
placeholder for a type that occupies none, which is a legal declaration
rather than an impossible one.
650 specs regenerated against master's binary: 1 file differs, and it
is the target. Elaboration 176 against baseline 176. Corpus ratchet
clean. Ledger tightened 2 -> 1.
THE REMAINING ENTRY IS NOT A BUG, and the arithmetic is now written
beside it:
Str { data: [4096]u8; len: u32 } = 4096*8 + 32 = 32,800
Map { keys: [64]Str; values: [64]Str;
count: u32 } = 2*64*32800 + 32 = 4,198,432
513 KiB in one packed register. The backend computed it faithfully; the
spec asked for something with no hardware form. Whether a type that
large should be lowerable is a design decision with a cost, and it is
filed with the same question about zero-width types rather than decided
here.
Three absurd widths, three unrelated mechanisms, two of them bugs. A
gate that catches a CLASS catches things outside the class it was
written for, and the discipline is to find the mechanism for each hit
rather than assume the one already fixed.
One more, on scope: searching for this underflow turned up 96 sites in
the compiler that format `[{}:0]` with a bare `- 1`, against 8 that use
saturating_sub. That is a candidate list, not a finding -- exactly one
of the 96 produces a bad width over the corpus, because the rest
operate on widths that cannot be zero. Fixing 95 unverifiable sites in
a compiler is a change nobody can defend later; the count is recorded,
the claim is not.
Refs #2566
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
Contributor
PR DashboardGenerated at: 2026-08-23 20:54:41 UTC
Summary
Seal Status
|
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.
var notebooks : [0]Notebookis a legal empty list. The packed-array path computestotal_width = dims[0] * elem_w— zero — and thentotal_width - 1on ausizeis 18446744073709551615:at exit 0, past every green gate. Two sites (1-D and multi-dimensional) clamped the way
range_declclamps.650 specs regenerated: 1 file differs, and it is the target. Elaboration 176 vs baseline 176. Corpus ratchet clean. Ledger tightened 2 → 1.
The remaining entry is not a bug
513 KiB in one packed register. The backend computed it faithfully; the spec asked for something with no hardware form. Whether a type that large should be lowerable is a design decision with a cost — filed with the same question about zero-width types, not decided here. The arithmetic now sits beside the ledger entry so the next reader does not look for a subtraction that is not there.
Three absurd widths, three unrelated mechanisms, two of them bugs. A gate that catches a class catches things outside the class it was written for; the discipline is to find the mechanism for each hit rather than assume the one already fixed.
On scope
Searching for this underflow turned up 96 sites formatting
[{}:0]with a bare- 1, against 8 usingsaturating_sub. That is a candidate list, not a finding: exactly one of the 96 produces a bad width over the corpus, because the rest operate on widths that cannot be zero. Fixing 95 unverifiable sites in a compiler is a change nobody can defend later — the count is recorded, the claim is not.§96 and §97.
Refs #2566