From 71758d6cd1093981c410b19b57fb11c0d2b2ff8a Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 5 Jul 2017 21:00:55 -0700 Subject: 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. --- struct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- cgit v1.2.3