cgen: load the full header for a wwstage global-dot slice field

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).
This commit is contained in:
2026-08-08 00:23:55 +09:00
parent 8a9be47f65
commit cc22abfc04
3 changed files with 35 additions and 5 deletions

View File

@@ -4242,7 +4242,12 @@ fn cgdot(c: *cgen, n: *syntax.node) void = {
cgloadtaggedfield(c, "CX", foff, tsz, true);
return;
};
if (syntax.typeisstr(ftraw)) {
// slice joins the str header load (#263: cstage
// N_DOT chain arm keys TY_STR||TY_SLICE — the
// same 24B {ptr,len,cap}); the scalar tail below
// pulled ONLY .ptr, so len(g.buf) read garbage.
if (syntax.typeisstr(ftraw)
|| syntax.typeisslice(ftraw)) {
emitline("\tMOVQ\t");
emitdispreg(foff: i64, "CX");
emitline(", AX\n");