wcc/ww: no-init array global emits one DATAW slot, not two
The str-size arm of the global data emit was size-keyed and matched a 24-sized array, emitting a second DATAW for the same symbol. Gate on the array kind (!isarr8). Review item #12.
This commit is contained in:
@@ -43467,7 +43467,14 @@ fn emitletdataw(c: *cgen, file: *node) void = {
|
||||
emitline("\"\n");
|
||||
};
|
||||
};
|
||||
if (sz == primtypesize("str"): i32 && !issg && !istup && !istagged && !letvarisslice(c, nm)) {
|
||||
// #12: this arm is SIZE-keyed (sz == 24), not type-keyed,
|
||||
// so a no-init array global whose bytes sum to str width
|
||||
// (e.g. `let g: [3]u64;`) matched here AND the TY_ARRAY arm
|
||||
// below → two identical `DATAW g` rows (cstage is type-
|
||||
// keyed via let_isstr and emits one). Exclude arrays — the
|
||||
// emitarraydata path owns them — mirroring the existing
|
||||
// isarr8 guard on the sz==8 scalar arm.
|
||||
if (sz == primtypesize("str"): i32 && !issg && !istup && !istagged && !isarr8 && !letvarisslice(c, nm)) {
|
||||
let r: *node = d.rhs;
|
||||
for (r != nil) {
|
||||
if (r.kind != nkind.N_CAST) { break; };
|
||||
|
||||
@@ -2936,7 +2936,14 @@ fn emitletdataw(c: *cgen, file: *node) void = {
|
||||
emitline("\"\n");
|
||||
};
|
||||
};
|
||||
if (sz == primtypesize("str"): i32 && !issg && !istup && !istagged && !letvarisslice(c, nm)) {
|
||||
// #12: this arm is SIZE-keyed (sz == 24), not type-keyed,
|
||||
// so a no-init array global whose bytes sum to str width
|
||||
// (e.g. `let g: [3]u64;`) matched here AND the TY_ARRAY arm
|
||||
// below → two identical `DATAW g` rows (cstage is type-
|
||||
// keyed via let_isstr and emits one). Exclude arrays — the
|
||||
// emitarraydata path owns them — mirroring the existing
|
||||
// isarr8 guard on the sz==8 scalar arm.
|
||||
if (sz == primtypesize("str"): i32 && !issg && !istup && !istagged && !isarr8 && !letvarisslice(c, nm)) {
|
||||
let r: *node = d.rhs;
|
||||
for (r != nil) {
|
||||
if (r.kind != nkind.N_CAST) { break; };
|
||||
|
||||
@@ -43467,7 +43467,14 @@ fn emitletdataw(c: *cgen, file: *node) void = {
|
||||
emitline("\"\n");
|
||||
};
|
||||
};
|
||||
if (sz == primtypesize("str"): i32 && !issg && !istup && !istagged && !letvarisslice(c, nm)) {
|
||||
// #12: this arm is SIZE-keyed (sz == 24), not type-keyed,
|
||||
// so a no-init array global whose bytes sum to str width
|
||||
// (e.g. `let g: [3]u64;`) matched here AND the TY_ARRAY arm
|
||||
// below → two identical `DATAW g` rows (cstage is type-
|
||||
// keyed via let_isstr and emits one). Exclude arrays — the
|
||||
// emitarraydata path owns them — mirroring the existing
|
||||
// isarr8 guard on the sz==8 scalar arm.
|
||||
if (sz == primtypesize("str"): i32 && !issg && !istup && !istagged && !isarr8 && !letvarisslice(c, nm)) {
|
||||
let r: *node = d.rhs;
|
||||
for (r != nil) {
|
||||
if (r.kind != nkind.N_CAST) { break; };
|
||||
|
||||
Reference in New Issue
Block a user