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:
@@ -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) {
|
||||
|
||||
@@ -2101,13 +2101,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;
|
||||
@@ -2116,7 +2127,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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user