[Issue 21693] extern(C++) class instance dtors are never called, breaking RAII

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 15 23:35:58 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=21693

--- Comment #5 from thomas.bockman at gmail.com ---
(In reply to kinke from comment #3)
> The GC could presumably handle C++ classes like structs, where the
> TypeInfo_Struct pointer is stored after the struct instance IIRC. For C++
> classes, it could store the D TypeInfo_Class pointer after the class
> instance (but note that class instances have no tail padding, so some
> padding might be needed for an aligned TypeInfo pointer).

That would be fine. The maximum overhead would be less than (size_t.sizeof *
2), which is no big deal if it gets RAII working properly.

Is it necessary to store a TypeInfo pointer for every instance, though? Garbage
collected instances would all be allocated on the D side, so I would think that
the TypeInfo data could just be stored adjacent to D's copy of the vtable.

--


More information about the Digitalmars-d-bugs mailing list