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 nested @[bitpacked] struct's chained field read returns wrong bits. Intermediate binding is correct, and backing casts are correct — only the two-level chained-read expression mis-shifts/masks.
Repro
@[bitpacked] type Inner { a: u2, b: u2 }
@[bitpacked] type Outer { hi: u4, inner: Inner }
fn main:
let o = Outer { hi: 0xF, inner: Inner { a: 2, b: 1 } }
print_i32(o.inner.a as i32) // prints 3, expected 2
print_i32(o.inner.b as i32) // prints 3, expected 1
let inr = o.inner
print_i32(inr.a as i32) // prints 2 (correct)
print_i32((o as u8) as i32) // 0xF9 (correct)
Deterministic. Intermediate let inr = o.inner; inr.a → correct; o as u8/o.inner as u8 → correct. So the chained-read shift/mask composition is wrong.
Spec §4.3b
Nested bitpacked field access. Candidate: the codegen path for a two-level bitpacked field projection composes the outer+inner shift/mask incorrectly.
Found
Coverage sweep #484, 2026-07-03. Single-level bitpacked (behav_bitpacked_single) works and is pinned; this nested case is the gap.
Fixed in dd451f8. The nested bitpacked projection loop overwrote the outer field's bit offset with the inner field's instead of accumulating them; o.inner.a now reads 2 (was 3). One site in mir_place_ptr accumulates offsets (existing+this, innermost width); the store RMW path shares the same projection map so nested writes are fixed too. Verified two- and three-level reads + nested writes; single-level unaffected. Fixpoint + full suite green; 3 fixtures.
Activity
test: coverage-sweep batch 2 (#483 #484 #522 #493 #494 #514 #515 #532)
ehartford commentedon Jul 5, 2026
Fixed in dd451f8. The nested bitpacked projection loop overwrote the outer field's bit offset with the inner field's instead of accumulating them; o.inner.a now reads 2 (was 3). One site in mir_place_ptr accumulates offsets (existing+this, innermost width); the store RMW path shares the same projection map so nested writes are fixed too. Verified two- and three-level reads + nested writes; single-level unaffected. Fixpoint + full suite green; 3 fixtures.
Fix #635: nested bitpacked field projection accumulates bit offsets