[Issue 19216] New: object.destroy doesn't handle Objective-C classes correctly

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Sep 4 11:26:50 UTC 2018


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

          Issue ID: 19216
           Summary: object.destroy doesn't handle Objective-C classes
                    correctly
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: doob at me.com

The code for "object.destroy" for classes looks like:

void destroy(T)(T obj) if (is(T == class))
{
    static if(__traits(getLinkage, T) == "C++")
    {
        obj.__xdtor();

        enum classSize = __traits(classInstanceSize, T);
        (cast(void*)obj)[0 .. classSize] = typeid(T).initializer[];
    }
    else
        rt_finalize(cast(void*)obj);
}

The code should check for Objective-C and potentially COM classes as well.

https://github.com/dlang/druntime/blob/14bd877bc51014baf9090175f2e690d8e1ec3a4a/src/object.d#L562

--


More information about the Digitalmars-d-bugs mailing list