let x: []T = g.buf on a module-global struct dispatched only str fields to the 3-word header load; a []T field fell to the scalar tail (ptr word only), so len/cap read stale registers and the shape was byteid-divergent against cstage's TY_STR||TY_SLICE arm (#263).
26 lines
626 B
Plaintext
26 lines
626 B
Plaintext
//ww:run
|
|
// A module-global struct's slice field read BY VALUE must load the
|
|
// full 24B {ptr,len,cap} header. The pre-fix wwstage global-dot arm
|
|
// dispatched only str fields to the header load; a []T field fell to
|
|
// the scalar tail (ptr word only) and len(x) read stale registers.
|
|
package main;
|
|
|
|
type box = struct {
|
|
buf: []i32,
|
|
name: str,
|
|
};
|
|
|
|
let g: box = box{};
|
|
|
|
export fn main() int = {
|
|
let arr: [4]i32 = [10, 20, 30, 40];
|
|
g.buf = arr[:];
|
|
g.name = "globals";
|
|
let x: []i32 = g.buf;
|
|
if (len(x) != 4) { return 1; };
|
|
if (x[2] != 30) { return 2; };
|
|
let s: str = g.name;
|
|
if (len(s) != 7) { return 3; };
|
|
return 0;
|
|
};
|