#dbugfix 17592

Simen Kjærås simen.kjaras at gmail.com
Wed Mar 21 11:13:41 UTC 2018


On Wednesday, 21 March 2018 at 08:49:11 UTC, Mike Franklin wrote:

> I think `rt_finalize` can be made `@nogc` in the runtime.

And this is where you're wrong. Consider this:

class A {
     @nogc ~this() {}
}

class B : A {
     ~this() {}
}

A a = new B();
destroy(a); // Is this @nogc?


Essentially, since @nogc and other qualifiers aren't inherited on 
dtors, it's impossible to know if destroying an instance of a 
non-final class is @nogc.

There's one case where you can: final classes where no superclass 
and no member defines a non- at nogc destructor.

In order for this to be done in the general case, dtors need to 
inherit their qualifiers somehow. That's at the very least a DIP, 
and any chosen path is highly likely to break existing code.

--
   Simen


More information about the Digitalmars-d mailing list