summaryrefslogtreecommitdiffstats
path: root/struct.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-07-05 21:00:55 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-07-05 21:00:55 -0700
commit71758d6cd1093981c410b19b57fb11c0d2b2ff8a (patch)
tree9bd175f1a4d06dc65162ee2c03eb9b4429ac3c76 /struct.c
parent3451e42d24f8ba117deeb3e44d6db6aefc78412a (diff)
downloadtxr-71758d6cd1093981c410b19b57fb11c0d2b2ff8a.tar.gz
txr-71758d6cd1093981c410b19b57fb11c0d2b2ff8a.tar.bz2
txr-71758d6cd1093981c410b19b57fb11c0d2b2ff8a.zip
structs: bugfix in static-slot-ensure.
* struct.c (static_sot_ens_rec): This change is in the case when a static slot is being ensured in a struct type which already has that static slot by inheritance. In that situation, the inheritance is severed and the struct gets its own non-inherited slot of that name. Then all of the derived structs are scanned. If any contain the original inherited slot, it is updated to the new, non-inherited one. The bug here is that we were copying the home_offs field of the original inherited slot to the new one! This is wrong; the new slot is not related to the original inherited one. The new slot is a home slot and its own offset must be home_offs. We can calculate that simply as its delta from the static slot table base.
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/struct.c b/struct.c
index 3b16da7c..6d72d2ae 100644
--- a/struct.c
+++ b/struct.c
@@ -1081,7 +1081,7 @@ static val static_slot_ens_rec(val stype, val sym, val newval,
to.store = nil;
to.home_type = stype;
to.home = &stsl->store;
- to.home_offs = stsl->home_offs;
+ to.home_offs = stsl - st->stslot;
static_slot_rewrite_rec(st, stsl, &to);
set(stslot_loc(stsl), newval);
return newval;