wcc: store to a global tagged-array element resolves the (SB) base (#16)

The indexed tagged-element assign arm computed its base without the
isglobal -> LEAQ name(SB) branch the scalar element arm already has, so
`gs[i] = v` on a global tagged array stored to a junk frame base and was
lost -- cstage rc=0 where wwstage (which has the branch) rc=42. Mirror
the scalar arm's base resolution; cstage aligns up to wwstage. Local
tagged arrays and scalar globals are unchanged.

The global tagged-array static initializer still mis-packs its DATA in
both stages -- a separate emitter path, filed as #19.
This commit is contained in:
2026-06-14 00:14:42 +09:00
parent 1074239859
commit 323607d1d0
3 changed files with 292 additions and 7 deletions

View File

@@ -513,6 +513,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
$(BIN)/test_structvariant_largeunion_return \
$(BIN)/test_narrow_alias_deref_store \
$(BIN)/test_taggedderefstore_run \
$(BIN)/test_taggedglobalindex_run \
$(BIN)/test_bufio_vstream_run \
$(BIN)/test_log_vstream_run \
$(BIN)/test_use_promote_alias \
@@ -839,6 +840,23 @@ $(BIN)/test_taggedderefstore_run: test/wcc/989_taggedderefstore_run.c \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
# 989_taggedglobalindex_run (#16): an indexed store into a GLOBAL tagged array
# `gs[i] = v` (gs:[N](A|B)) — the indexed-tagged-element assign arm (cmd/w6c/
# cgen.c ~6502) lacked the `isglobal -> LEAQ name(SB)` base branch the scalar
# `arr[i]=v` element arm (~6767) already had, so the global base resolved to a
# junk BP offset and the widened store landed nowhere; cstage silently returned
# 0 while wwstage (cgenexpr.ww index arm, already global-aware) returned the
# correct value — a cs!=ww divergence the byte-id gate could SEE. #16 aligns
# cstage UP with the mirrored isglobal branch. Builds+runs on BOTH driver twins
# (rule-10), pinning the absolute 0; loc_ctl + scalar_ctl pin the unchanged
# frame-base and scalar-template paths.
$(BIN)/test_taggedglobalindex_run: test/wcc/989_taggedglobalindex_run.c \
$(BIN)/ww $(BIN)/ww_ww \
$(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
$(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
# 989_arrlit_tail_zero_run (#13): an under-length array literal zero-fills the
# unspecified tail, not the last value. Builds+runs on BOTH driver twins
# (rule-10), pinning the absolute value (pre-fix ww tail = last value).