wcc/ww: under-length array-literal tail zero-fills

The unspecified tail of a short array literal repeated the last value
instead of zeroing — wwstage only (cstage already zeroes; the review's
both-stages reading didn't survive ground truth). Zero-fill the tail
per the zero-value semantics ruling. Review item #13.
This commit is contained in:
2026-06-13 00:17:57 +09:00
parent 94a55c565f
commit ffb858bba6
5 changed files with 214 additions and 9 deletions

View File

@@ -42632,13 +42632,24 @@ fn emitarraylitbytes(c: *cgen, arrt: *tinfo, rhs: *node,
e = rhs.list;
let inrepeat: bool = false;
for (idx < alen) {
let v: u64 = last;
if (!inrepeat && e != nil) {
// #13: explicit elements fold normally; a `...` repeat replays the
// LAST value; the tail PAST the explicit elements (no `...`) is
// ZERO-filled. Pre-fix the default was `last`, so an under-length
// literal (`[4]u64 = [1, 2]`) repeated the last value into the tail
// instead of zero — cstage already zeroes (Hare: unspecified array
// elements are zeroed; the #16-task zero-value ruling); this aligns
// wwstage, a gate-blind cs!=ww divergence at the array-global path.
let v: u64 = 0u64;
if (inrepeat) {
v = last;
} else { if (e != nil) {
if (e.kind == nkind.N_FIELD) {
if (streq(e.str, "...")) {
inrepeat = true;
v = last;
} else {
e = e.next;
v = last;
};
} else {
let ev: *node = e;
@@ -42647,7 +42658,7 @@ fn emitarraylitbytes(c: *cgen, arrt: *tinfo, rhs: *node,
last = v;
e = e.next;
};
};
};};
let nb: u64 = v;
let bb: i32 = 0;
for (bb < esz) {