diff --git a/Makefile b/Makefile index a768bd2f..44331d72 100644 --- a/Makefile +++ b/Makefile @@ -402,6 +402,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \ $(BIN)/test_deref_narrow_run \ $(BIN)/test_idx_compound_run \ $(BIN)/test_dotbase_arr_run \ + $(BIN)/test_dotbase_addr_slice_run \ $(BIN)/test_structlit_arrfield_run \ $(BIN)/test_continue_run \ $(BIN)/test_callret_unsigned_arith_run \ @@ -1594,6 +1595,11 @@ $(BIN)/test_dotbase_arr_run: test/wcc/949_dotbase_arr_run.c $(BIN)/ww \ $(LIB)/libwwrt.a | $(BIN) $(CC) $(CFLAGS) -o $@ $< +$(BIN)/test_dotbase_addr_slice_run: test/wcc/949_dotbase_addr_slice_run.c \ + $(BIN)/ww $(BIN)/w6c $(BIN)/w6c_ww $(BIN)/w6a $(BIN)/w6l \ + $(LIB)/libwwrt.a | $(BIN) + $(CC) $(CFLAGS) -o $@ $< + $(BIN)/test_structlit_arrfield_run: test/wcc/949_structlit_arrfield_run.c \ $(BIN)/ww $(BIN)/w6c $(BIN)/w6c_ww $(BIN)/w6a $(BIN)/w6l \ $(LIB)/libwwrt.a | $(BIN) diff --git a/cmd/w6c/cgen.c b/cmd/w6c/cgen.c index f6a7ed5b..e85b30f0 100644 --- a/cmd/w6c/cgen.c +++ b/cmd/w6c/cgen.c @@ -3255,9 +3255,14 @@ cgexpr(Cg *c, Node *n, Local *locals) break; } /* Complex base: eval to AX, swap into BX, - * then add the saved scaled idx. */ + * then add the saved scaled idx. #252: an + * N_DOT `[N]T`-field base needs the field + * ADDRESS (cg_dotbase_addr LEAQ) — cgexpr would + * auto-deref + load the field VALUE as a pointer + * (segfault). Sibling of the #135 read-side wiring. */ ins1(c, A_PUSHQ, areg(D_AX)); - cgexpr(c, base, locals); + if (!cg_dotbase_addr(c, base, D_AX, locals)) + cgexpr(c, base, locals); ins1(c, A_POPQ, areg(D_BX)); ins2(c, A_ADDQ, areg(D_BX), areg(D_AX)); break; @@ -8168,10 +8173,14 @@ cgexpr(Cg *c, Node *n, Local *locals) Node *hi = n->cond; Type *bt = base ? base->type : NULL; Type *bu = (bt && bt->kind == TY_NAMED) ? bt->under : bt; - /* N_IDENT-gated: non-ident bases stay esz=1 (unscaled), - * byte-id with wwstage which has no tnode there to resolve - * esz (rule 10) -- #76 residual, non-ident cluster #74. */ - int esz = (base && base->kind == N_IDENT && bu && bu->sub) + /* esz from the type table for an N_IDENT base (#76) or an + * N_DOT array/slice-field base (#252: a struct-field slice + * `s.obuf[lo:hi]` must scale by the field's element width, not + * stay esz=1 — silently wrong for non-u8 elements). Other + * non-ident bases stay esz=1 (unscaled) -- #76 residual, + * non-ident cluster #74. */ + int esz = (base && (base->kind == N_IDENT + || base->kind == N_DOT) && bu && bu->sub) ? (int)bu->sub->size : 1; if (base && base->kind == N_IDENT) { int boff = localfind(locals, base->str); @@ -8188,7 +8197,11 @@ cgexpr(Cg *c, Node *n, Local *locals) ins2(c, A_MOVQ, amem(D_BP, boff), areg(D_AX)); } } else if (base) { - cgexpr(c, base, locals); + /* #252: N_DOT `[N]T`-field base → field ADDRESS via + * cg_dotbase_addr (LEAQ), not the auto-deref VALUE load + * cgexpr would emit. Sibling of the #135 read-side. */ + if (!cg_dotbase_addr(c, base, D_AX, locals)) + cgexpr(c, base, locals); } ins1(c, A_PUSHQ, areg(D_AX)); if (lo) cgexpr(c, lo, locals); diff --git a/selfhost/cmd/w6c/main.combined.ww b/selfhost/cmd/w6c/main.combined.ww index 9d50596e..55e57569 100644 --- a/selfhost/cmd/w6c/main.combined.ww +++ b/selfhost/cmd/w6c/main.combined.ww @@ -20727,15 +20727,29 @@ fn cgslice(c: *cgen, n: *node) void = { }; }; }; + // #252: an N_DOT `[N]T`-field base (`s.obuf[lo:hi]`) carries no + // tnode — resolve esz / default-hi / base-address from the checker- + // stamped element tinfo on base.type_ instead. Cstage twin reads + // base->type (cgen.c N_SLICE esz + bu->kind==TY_ARRAY default-hi). + let dotbu: *tinfo = nil; + if (base != nil) { if (base.kind == nkind.N_DOT) { + dotbu = base.type_: *tinfo; + for (dotbu != nil && dotbu.kind == tykind.TY_NAMED) { + dotbu = dotbu.under; + }; + };}; // esz from the type table for an N_IDENT base (#76; mirrors the - // cgindex idiom). Non-ident base stays esz=1 -> ptr unscaled, - // matching cstage's base->kind==N_IDENT gate. + // cgindex idiom) or an N_DOT array/slice-field base (#252: scale by + // the field's element width, not esz=1 — silently wrong for non-u8). + // Other non-ident bases stay esz=1 -> ptr unscaled. let esz: i32 = 1; if (baselocal != nil) { esz = elemsizeofc(c, baselocal.tnode); } else { if (globaltn != nil) { esz = elemsizeofc(c, globaltn); - };}; + } else { if (dotbu != nil && dotbu.sub != nil) { + esz = dotbu.sub.size: i32; + };};}; // base address if (baselocal != nil) { let tn: *node = baselocal.tnode; @@ -20766,7 +20780,12 @@ fn cgslice(c: *cgen, n: *node) void = { emitline("(SB), AX\n"); }; } else { if (base != nil) { - cgexpr(c, base); + // #252: N_DOT `[N]T`-field base → field ADDRESS via + // dotbaseaddr (LEAQ), not the auto-deref VALUE load cgexpr + // emits. Sibling of the #135 read-side. + if (!dotbaseaddr(c, base, "AX")) { + cgexpr(c, base); + }; };};}; emitline("\tPUSHQ\tAX\n"); // lo (default 0) @@ -20825,9 +20844,16 @@ fn cgslice(c: *cgen, n: *node) void = { handled = true; };}; if (!handled) { emitline("\tMOVQ\t$0, AX\n"); }; + } else { if (dotbu != nil && dotbu.kind == tykind.TY_ARRAY) { + // #252: default-hi `s.obuf[lo:]` on a struct array-field → + // element count from the field's array tinfo. Cstage twin + // cgexpr_int(bu->alen) (cgen.c N_SLICE default-hi). + emitline("\tMOVQ\t$"); + emitint(dotbu.alen: i64); + emitline(", AX\n"); } else { emitline("\tMOVQ\t$0, AX\n"); - };};}; + };};};}; emitline("\tMOVQ\tAX, BX\n"); emitline("\tPOPQ\tCX\n"); emitline("\tPOPQ\tAX\n"); @@ -22538,8 +22564,14 @@ fn cgun(c: *cgen, n: *node) void = { // + POPQ AX scratch shuffle was rule-10 // verbose-defensive on the wwstage side // with no semantic asymmetry (task #21). + // #252: an N_DOT `[N]T`-field base needs the + // field ADDRESS (dotbaseaddr LEAQ), not the + // auto-deref VALUE load cgexpr emits. Sibling + // of the #135 read-side wiring. emitline("\tPUSHQ\tAX\n"); - cgexpr(c, base); + if (!dotbaseaddr(c, base, "AX")) { + cgexpr(c, base); + }; emitline("\tPOPQ\tBX\n"); };};}; emitline("\tADDQ\tBX, AX\n"); diff --git a/selfhost/cmd/wcc/cgenexpr.ww b/selfhost/cmd/wcc/cgenexpr.ww index e1c6cc6f..19bc2511 100644 --- a/selfhost/cmd/wcc/cgenexpr.ww +++ b/selfhost/cmd/wcc/cgenexpr.ww @@ -1429,15 +1429,29 @@ fn cgslice(c: *cgen, n: *node) void = { }; }; }; + // #252: an N_DOT `[N]T`-field base (`s.obuf[lo:hi]`) carries no + // tnode — resolve esz / default-hi / base-address from the checker- + // stamped element tinfo on base.type_ instead. Cstage twin reads + // base->type (cgen.c N_SLICE esz + bu->kind==TY_ARRAY default-hi). + let dotbu: *tinfo = nil; + if (base != nil) { if (base.kind == nkind.N_DOT) { + dotbu = base.type_: *tinfo; + for (dotbu != nil && dotbu.kind == tykind.TY_NAMED) { + dotbu = dotbu.under; + }; + };}; // esz from the type table for an N_IDENT base (#76; mirrors the - // cgindex idiom). Non-ident base stays esz=1 -> ptr unscaled, - // matching cstage's base->kind==N_IDENT gate. + // cgindex idiom) or an N_DOT array/slice-field base (#252: scale by + // the field's element width, not esz=1 — silently wrong for non-u8). + // Other non-ident bases stay esz=1 -> ptr unscaled. let esz: i32 = 1; if (baselocal != nil) { esz = elemsizeofc(c, baselocal.tnode); } else { if (globaltn != nil) { esz = elemsizeofc(c, globaltn); - };}; + } else { if (dotbu != nil && dotbu.sub != nil) { + esz = dotbu.sub.size: i32; + };};}; // base address if (baselocal != nil) { let tn: *node = baselocal.tnode; @@ -1468,7 +1482,12 @@ fn cgslice(c: *cgen, n: *node) void = { emitline("(SB), AX\n"); }; } else { if (base != nil) { - cgexpr(c, base); + // #252: N_DOT `[N]T`-field base → field ADDRESS via + // dotbaseaddr (LEAQ), not the auto-deref VALUE load cgexpr + // emits. Sibling of the #135 read-side. + if (!dotbaseaddr(c, base, "AX")) { + cgexpr(c, base); + }; };};}; emitline("\tPUSHQ\tAX\n"); // lo (default 0) @@ -1527,9 +1546,16 @@ fn cgslice(c: *cgen, n: *node) void = { handled = true; };}; if (!handled) { emitline("\tMOVQ\t$0, AX\n"); }; + } else { if (dotbu != nil && dotbu.kind == tykind.TY_ARRAY) { + // #252: default-hi `s.obuf[lo:]` on a struct array-field → + // element count from the field's array tinfo. Cstage twin + // cgexpr_int(bu->alen) (cgen.c N_SLICE default-hi). + emitline("\tMOVQ\t$"); + emitint(dotbu.alen: i64); + emitline(", AX\n"); } else { emitline("\tMOVQ\t$0, AX\n"); - };};}; + };};};}; emitline("\tMOVQ\tAX, BX\n"); emitline("\tPOPQ\tCX\n"); emitline("\tPOPQ\tAX\n"); @@ -3240,8 +3266,14 @@ fn cgun(c: *cgen, n: *node) void = { // + POPQ AX scratch shuffle was rule-10 // verbose-defensive on the wwstage side // with no semantic asymmetry (task #21). + // #252: an N_DOT `[N]T`-field base needs the + // field ADDRESS (dotbaseaddr LEAQ), not the + // auto-deref VALUE load cgexpr emits. Sibling + // of the #135 read-side wiring. emitline("\tPUSHQ\tAX\n"); - cgexpr(c, base); + if (!dotbaseaddr(c, base, "AX")) { + cgexpr(c, base); + }; emitline("\tPOPQ\tBX\n"); };};}; emitline("\tADDQ\tBX, AX\n"); diff --git a/selfhost/cmd/wwdump/main.combined.ww b/selfhost/cmd/wwdump/main.combined.ww index a657c281..2930dc74 100644 --- a/selfhost/cmd/wwdump/main.combined.ww +++ b/selfhost/cmd/wwdump/main.combined.ww @@ -20727,15 +20727,29 @@ fn cgslice(c: *cgen, n: *node) void = { }; }; }; + // #252: an N_DOT `[N]T`-field base (`s.obuf[lo:hi]`) carries no + // tnode — resolve esz / default-hi / base-address from the checker- + // stamped element tinfo on base.type_ instead. Cstage twin reads + // base->type (cgen.c N_SLICE esz + bu->kind==TY_ARRAY default-hi). + let dotbu: *tinfo = nil; + if (base != nil) { if (base.kind == nkind.N_DOT) { + dotbu = base.type_: *tinfo; + for (dotbu != nil && dotbu.kind == tykind.TY_NAMED) { + dotbu = dotbu.under; + }; + };}; // esz from the type table for an N_IDENT base (#76; mirrors the - // cgindex idiom). Non-ident base stays esz=1 -> ptr unscaled, - // matching cstage's base->kind==N_IDENT gate. + // cgindex idiom) or an N_DOT array/slice-field base (#252: scale by + // the field's element width, not esz=1 — silently wrong for non-u8). + // Other non-ident bases stay esz=1 -> ptr unscaled. let esz: i32 = 1; if (baselocal != nil) { esz = elemsizeofc(c, baselocal.tnode); } else { if (globaltn != nil) { esz = elemsizeofc(c, globaltn); - };}; + } else { if (dotbu != nil && dotbu.sub != nil) { + esz = dotbu.sub.size: i32; + };};}; // base address if (baselocal != nil) { let tn: *node = baselocal.tnode; @@ -20766,7 +20780,12 @@ fn cgslice(c: *cgen, n: *node) void = { emitline("(SB), AX\n"); }; } else { if (base != nil) { - cgexpr(c, base); + // #252: N_DOT `[N]T`-field base → field ADDRESS via + // dotbaseaddr (LEAQ), not the auto-deref VALUE load cgexpr + // emits. Sibling of the #135 read-side. + if (!dotbaseaddr(c, base, "AX")) { + cgexpr(c, base); + }; };};}; emitline("\tPUSHQ\tAX\n"); // lo (default 0) @@ -20825,9 +20844,16 @@ fn cgslice(c: *cgen, n: *node) void = { handled = true; };}; if (!handled) { emitline("\tMOVQ\t$0, AX\n"); }; + } else { if (dotbu != nil && dotbu.kind == tykind.TY_ARRAY) { + // #252: default-hi `s.obuf[lo:]` on a struct array-field → + // element count from the field's array tinfo. Cstage twin + // cgexpr_int(bu->alen) (cgen.c N_SLICE default-hi). + emitline("\tMOVQ\t$"); + emitint(dotbu.alen: i64); + emitline(", AX\n"); } else { emitline("\tMOVQ\t$0, AX\n"); - };};}; + };};};}; emitline("\tMOVQ\tAX, BX\n"); emitline("\tPOPQ\tCX\n"); emitline("\tPOPQ\tAX\n"); @@ -22538,8 +22564,14 @@ fn cgun(c: *cgen, n: *node) void = { // + POPQ AX scratch shuffle was rule-10 // verbose-defensive on the wwstage side // with no semantic asymmetry (task #21). + // #252: an N_DOT `[N]T`-field base needs the + // field ADDRESS (dotbaseaddr LEAQ), not the + // auto-deref VALUE load cgexpr emits. Sibling + // of the #135 read-side wiring. emitline("\tPUSHQ\tAX\n"); - cgexpr(c, base); + if (!dotbaseaddr(c, base, "AX")) { + cgexpr(c, base); + }; emitline("\tPOPQ\tBX\n"); };};}; emitline("\tADDQ\tBX, AX\n"); diff --git a/test/wcc/949_dotbase_addr_slice_run.c b/test/wcc/949_dotbase_addr_slice_run.c new file mode 100644 index 00000000..4d83a46e --- /dev/null +++ b/test/wcc/949_dotbase_addr_slice_run.c @@ -0,0 +1,239 @@ +/* + * 949_dotbase_addr_slice_run — runtime + byte-id net for #252, the + * addr-of + slice SIBLING of #135 (949_dotbase_arr_run covers the + * read/write index path). Taking `&x.o[i]` (address-of an element) or + * slicing `x.o[lo:hi]` / `x.o[lo:]` of a struct's `[N]T`-typed FIELD + * computed the field's VALUE as the base address instead of its + * ADDRESS: cgen emitted `MOVL off(BP),AX` (load the field's first + * 8 bytes as a pointer) where it must emit `LEAQ off(BP),AX` (the + * field's address) -> garbage pointer -> SEGFAULT. The index + * read/write path was fixed in #135; the addr-of N_INDEX "complex + * base" arm and the N_SLICE base arm still fell to the generic + * cgexpr(base) auto-deref. cs==ww BOTH stages broken identically + * pre-fix (gate-blind, pure correctness — not a byte-id divergence). + * + * Fix wires the same `cg_dotbase_addr` (cstage) / `dotbaseaddr` + * (wwstage) helper #135 introduced into those two base-address paths + * (guarded `if(!cg_dotbase_addr(...)) cgexpr(base)`). For the slice + * path the element stride (esz) and default-hi length are extended to + * an N_DOT array-field base too (read from the field's element tinfo / + * array length via the type table — rule-13), so non-u8 element slices + * scale correctly and `s.obuf[lo:]` gets the array's element count. + * + * Rows (cstage `ww build` + run for exit code; w6c vs w6c_ww `.s` cmp + * for rule-10 byte-id): + * - addr_local_u8 &x.o[1] on a local value-struct, *p read → 66 + * - addr_ptr_u8 &x.o[2] via a *struct param, *p read → 77 + * - slice_u8_expl x.o[1:4] explicit hi, s[0] read → 66 + * - slice_u8_dflthi x.o[1:] default hi, s[0] read → 66 + * - slice_i32_expl [4]i32 field x.o[1:3], s[1] read (esz=4) → 88 + * - slice_i32_dflt [4]i32 field x.o[1:], s[2] read (esz=4) → 55 + * - control_bare bare-local [4]u8 &a[1] write + a[1:4] read → 44 + * + * The bare-local control asserts the N_IDENT base paths (untouched by + * this fix) still emit correct code; the non-u8 rows assert the esz + * stride extension is wired (not silently esz=1). + */ +#include +#include +#include +#include +#include +#include + +static int +runwait(const char *cmd) +{ + int rc = system(cmd); + if (rc == -1) return -1; + if (WIFEXITED(rc)) return WEXITSTATUS(rc); + return -1; +} + +struct row { const char *label; const char *src; int want_exit; }; + +static const struct row rows[] = { + { "addr_local_u8", + "package main;\n" + "type e = struct { o: [4]u8 };\n" + "export fn main() i32 = {\n" + " let x: e;\n" + " x.o[1] = 66u8;\n" + " let p: *u8 = &x.o[1];\n" + " return (*p): i32;\n" + "};\n", 66 }, + { "addr_ptr_u8", + "package main;\n" + "type e = struct { o: [4]u8 };\n" + "fn rd(x: *e) u8 = { let p: *u8 = &x.o[2]; return *p; };\n" + "export fn main() i32 = {\n" + " let x: e;\n" + " x.o[2] = 77u8;\n" + " return rd(&x): i32;\n" + "};\n", 77 }, + { "slice_u8_expl", + "package main;\n" + "type e = struct { o: [4]u8 };\n" + "export fn main() i32 = {\n" + " let x: e;\n" + " x.o[1] = 66u8;\n" + " let s: []u8 = x.o[1:4];\n" + " return s[0]: i32;\n" + "};\n", 66 }, + { "slice_u8_dflthi", + "package main;\n" + "type e = struct { o: [4]u8 };\n" + "export fn main() i32 = {\n" + " let x: e;\n" + " x.o[1] = 66u8;\n" + " let s: []u8 = x.o[1:];\n" + " return s[0]: i32;\n" + "};\n", 66 }, + { "slice_i32_expl", + "package main;\n" + "type e = struct { o: [4]i32 };\n" + "export fn main() i32 = {\n" + " let x: e;\n" + " x.o[1] = 99;\n" + " x.o[2] = 88;\n" + " let s: []i32 = x.o[1:3];\n" + " return s[1];\n" + "};\n", 88 }, + { "slice_i32_dflt", + "package main;\n" + "type e = struct { o: [4]i32 };\n" + "export fn main() i32 = {\n" + " let x: e;\n" + " x.o[3] = 55;\n" + " let s: []i32 = x.o[1:];\n" + " return s[2];\n" + "};\n", 55 }, + { "control_bare", + "package main;\n" + "export fn main() i32 = {\n" + " let a: [4]u8;\n" + " a[2] = 44u8;\n" + " let p: *u8 = &a[1];\n" + " *p = 33u8;\n" + " let s: []u8 = a[1:4];\n" + " return s[1]: i32;\n" + "};\n", 44 }, + { NULL, NULL, 0 } +}; + +static int +slurp_eq(const char *a, const char *b) +{ + FILE *fa = fopen(a, "rb"); + FILE *fb = fopen(b, "rb"); + if (!fa || !fb) { if (fa) fclose(fa); if (fb) fclose(fb); return -1; } + int rc = 0; + for (;;) { + int ca = fgetc(fa); + int cb = fgetc(fb); + if (ca != cb) { rc = -1; break; } + if (ca == EOF) break; + } + fclose(fa); fclose(fb); + return rc; +} + +int +main(void) +{ + const char *bin = getenv("BIN"); + if (!bin) bin = "out/bin"; + char absbin[1024]; + if (bin[0] != '/') { + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin); + bin = absbin; + } + + char w6c[1100], w6c_ww[1100]; + snprintf(w6c, sizeof w6c, "%s/w6c", bin); + snprintf(w6c_ww, sizeof w6c_ww, "%s/w6c_ww", bin); + if (access(w6c_ww, X_OK) != 0) { + fprintf(stderr, "dotbaseaddr: w6c_ww missing — cannot run the " + "cs==ww byte-id gate (the whole point of this test)\n"); + return 1; + } + + int n = 0, fail = 0; + for (int i = 0; rows[i].src; i++, n++) { + char src[64]; + snprintf(src, sizeof src, "/tmp/wwdbs_%d_%d.ww", getpid(), i); + FILE *f = fopen(src, "wb"); + if (f == NULL) { fail++; continue; } + fputs(rows[i].src, f); + fclose(f); + + char tmpdir[64]; + snprintf(tmpdir, sizeof tmpdir, "/tmp/wwdbs_%d_d_%d", + getpid(), i); + mkdir(tmpdir, 0755); + + char cmd[2048]; + snprintf(cmd, sizeof cmd, "cd %s && %s/ww build %s", + tmpdir, bin, src); + if (runwait(cmd) != 0) { + fprintf(stderr, "row[%s]: cstage build failed\n", + rows[i].label); + fail++; + unlink(src); rmdir(tmpdir); + continue; + } + + char outbin[128]; + const char *base = strrchr(src, '/'); + base = base ? base + 1 : src; + snprintf(outbin, sizeof outbin, "%s/%s", tmpdir, base); + char *dot = strrchr(outbin, '.'); + if (dot && strcmp(dot, ".ww") == 0) *dot = '\0'; + + int got = runwait(outbin); + if (got != rows[i].want_exit) { + fprintf(stderr, "row[%s]: cstage exit %d, want %d\n", + rows[i].label, got, rows[i].want_exit); + fail++; + } + unlink(outbin); rmdir(tmpdir); + + char cs_s[64], ws_s[64]; + snprintf(cs_s, sizeof cs_s, "/tmp/wwdbs_%d_%d_cs.s", + getpid(), i); + snprintf(ws_s, sizeof ws_s, "/tmp/wwdbs_%d_%d_ww.s", + getpid(), i); + + snprintf(cmd, sizeof cmd, "%s -o %s %s 2>/dev/null", + w6c, cs_s, src); + if (runwait(cmd) != 0) { + fprintf(stderr, "row[%s]: w6c failed\n", rows[i].label); + fail++; unlink(src); continue; + } + snprintf(cmd, sizeof cmd, "%s -o %s %s 2>/dev/null", + w6c_ww, ws_s, src); + if (runwait(cmd) != 0) { + fprintf(stderr, "row[%s]: w6c_ww failed\n", + rows[i].label); + fail++; unlink(src); unlink(cs_s); continue; + } + if (slurp_eq(cs_s, ws_s) != 0) { + fprintf(stderr, + "row[%s]: cstage/wwstage .s DIFFER (rule-10 " + "byte-id violation)\n", rows[i].label); + fail++; + } + unlink(src); unlink(cs_s); unlink(ws_s); + } + + if (fail) { + fprintf(stderr, "%d/%d dotbase-addr-slice tests failed\n", + fail, n); + return 1; + } + printf("dotbaseaddr: %d/%d ok (cstage run + cs==ww byte-id)\n", + n, n); + return 0; +}