summaryrefslogtreecommitdiffstats
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
commit03cfc001998d2f203face905bc7126fc98cf7e03 (patch)
tree9bd175f1a4d06dc65162ee2c03eb9b4429ac3c76
parent9b7c9ae987f2c3ed75388434a32cbd8bc5fe7712 (diff)
downloadtxr-03cfc001998d2f203face905bc7126fc98cf7e03.tar.gz
txr-03cfc001998d2f203face905bc7126fc98cf7e03.tar.bz2
txr-03cfc001998d2f203face905bc7126fc98cf7e03.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.
-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;