Repository navigation
gen-c: a range slice is a pointer and an untyped array-literal local is an array (D5 of #11183) - #11240
Merged
Conversation
…is an array (D5 of #11183; Closes #11183) `a[lo..hi]` was written `a[(lo .. hi)]` and `a[lo..]` / `a[lo:hi]` were written `a[lo]` (an element, silently); an untyped list local (`const a = [Mode.Idle, Mode.Halt]`) was written `__auto_type a = { .. }`. A slice is a pointer in C, so a range slice is `(a + lo)`, a slice local with a declared type is `T* x`, and an untyped list declares `T a[N]` with the type of its first non-number element (`__typeof__`), as a module constant list now does too. D4 (the slice length) is not decided here and D7 (gen-verilog, pointer parameters) needs a ledger decision: see the PR. Hand Rust is net -80 (compiler.rs +40/-20, tests +3/-1, the dead handle_task_start stub of bridge.rs -117); FROZEN_HASH carries the new digest of compiler.rs. 243 specs re-sealed (gen_hash_c only). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Closes #11239
Refs #11183 (D4 is measured in a comment there; D7 is reproduced and left out, see below).
What changes
gen-cinbootstrap/src/compiler.rs(+40/-20):a[lo..hi],a[lo..],a[lo:hi]is the pointer(a + lo); it wasa[(lo .. hi)](not C) or the elementa[lo](silent);T* x; it wasT x[] = ptr;c_list_elem); it was__auto_type a = {..}orstatic const int NAME = {..}.Evidence
cc -std=c11 -fsyntax-only: range slice 594 probe cells, 44 compile (all taking the element) versus 528; untyped list 296 cells, 131 versus 196. The matrices were run locally by lane L3 and are not committed. The repeatable part is committed:specs/compiler/c_array_repeat_wrapper.t27(+31 lines, new range cases) andbootstrap/tests/fixtures/core_selfhost/genc/untyped_list.t27, which fails with 20ccerrors on master (the reviewer reproduced the 20).gen-cover the 2,882 tracked.t27files: 2,566 identical, 316 changed, 0 newly refused; none of the 26 committedgen/cfiles changes.gen_hash_conly). 4 seals were edited by hand,gen_hash_conly, becauseseal --savecannot run their Zig tests here:eval_hslm,host_io_model,train_slice_model,train_hslm.check_seal_currency0 stale,check_seal_coverageOK.FROZEN_HASHequals the SHA-256 of the committedcompiler.rs(5aec047d4..., checked by the reviewer).compiler.rs+40/-20, test +3/-1, and the never-used stubhandle_task_startinbridge.rs-117 (the compiler flags it as dead) pays the budget.c_literal_list_type.rshad a negative control that a mixed number-and-call list keeps__auto_type; it now expects__typeof__(cast_i8(2)) x[2].Not in this change
gen-verilogfields of a pointer or slice parameter): reproduced; a refusing pre-scan would newly refuse 608 specs (about 600 ledger rows) and the skip alternative rewrites 608 specs. The held code and test are in a comment on [bug] gen-c / gen-verilog: a slice parameter loses its length in C, two C forms do not compile, and Verilog leaves pointer-parameter fields unbound #11183. Decision with [bug] gen-rust: a []T struct field filled from borrowed storage is written Vec<T> and moves the caller's storage (D2 of #11182) #11218._ = [..],return [..](184 corpus sites), empty and nested lists, an untyped[v] ** n, one-element text lists, enum members or calls in module constants.t27c suite --ratchet --corpus-only, the fullcargo test -p t27c, a gcc run (clang only).🤖 Generated with Claude Code