src/class-layout-impl.lisp: Fix class pointers in secondary chains.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 8 Aug 2019 19:07:48 +0000 (20:07 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 8 Aug 2019 19:07:48 +0000 (20:07 +0100)
commit267aeb614f1d2bdbd92019abb126a52de642ba21
tree257c76fb66443e69c35621188a22249028413c48
parent67678b0be4da2701655d3d52db205d815f0687ea
src/class-layout-impl.lisp: Fix class pointers in secondary chains.

Consider:

[link = SodClass] class MyClass: SodClass { }
[metaclass = MyClass] class Foo: SodObject { }

GCC reports:

/tmp/mdw/t.c:258:33: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
   /*                _class = */ &Foo__classobj.obj.myclass,
                                 ^
/tmp/mdw/t.c:258:33: note: (near initialization for ‘Foo__vtable_obj.obj._class’)

What's going on here is that it's writing the wrong metaclass pointer
into the `_class' pointer on `Foo''s secondary `obj' chain.

Fix this by choosing, for each class pointer, the most specific
superclass of the overall metaclass that is (a) on the correct chain of
the metaclass, and (b) is a superclass of the metaclass of the most
specific class in the chain whose vtable we're writing.  Whew!
src/class-layout-impl.lisp