// overcap_tuple_field_store_test — project #234: storing the result of an // over-capacity tuple-returning call (sret: ([]u8,[]u8) = 6 GP) into a struct // field or an indexed lvalue. Migrated from // test/wcc/940_overcap_tuple_field_store_run.c. A FIELD or INDEXED dest stayed // unwired: the store dropped the callee's sret body (a truncated MOVQ through a // stale RDI), a SILENT miscompile gate-blind because the bootstrap never // field-stores a wide tuple. The fix points the callee's hidden sret dest // straight at the destination slot when it is a LOCAL (BP-relative). These // @test fns pin the runtime contract (T1, exit 0 both stages); the byte-id // gate (T2) keeps cs==ww. Every other dest (via_ptr / global / runtime-index / // N_DOT-base index / chained index) HARD-ERRORS LOUD (#234-tail) and lives as a // reject carrier (test/wcc/data/overcap_*_be/). cap != len in every wide // element so a dropped len OR cap is caught. package overcap_tuple_field_store_test; fn wide() ([]u8, []u8) = { let a: []u8; a.len = 1; a.cap = 5; let b: []u8; b.len = 2; b.cap = 6; return (a, b); }; type S_struct_field = struct { hdr: int, f: ([]u8, []u8) }; // indexed_local — `arr[1] = wide()`, arr: [2]([]u8,[]u8). Readback via // `(&arr[1]):*int` p[i] (a tuple-element READ arr[1].N is a separate gap, filed // #238) — len0=1, cap0=5, len1=2, cap1=6. @test fn indexed_local() void = { let arr: [2]([]u8, []u8); arr[1] = wide(); let p: *int = (&arr[1]): *int; assert(!(p[1] != 1)); assert(!(p[2] != 5)); assert(!(p[4] != 2)); assert(!(p[5] != 6)); }; // struct_field — `s.f = wide()`, S = struct { hdr:int, f:([]u8,[]u8) }. foff!=0 // (after hdr) + hdr-uncorrupted check. Pointer readback `(&s.f):*int`. @test fn struct_field() void = { let s: S_struct_field; s.hdr = 99; s.f = wide(); assert(!(s.hdr != 99)); let p: *int = (&s.f): *int; assert(!(p[1] != 1)); assert(!(p[2] != 5)); assert(!(p[4] != 2)); assert(!(p[5] != 6)); };