[Issue 17297] Object.~this not being @nogc is severely limiting @nogc applicability

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Apr 7 09:13:42 PDT 2017


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

Marco Leise <Marco.Leise at gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Marco.Leise at gmx.de

--- Comment #2 from Marco Leise <Marco.Leise at gmx.de> ---
A previous bug report about rt_finalize and @nogc is issue 15246. It takes a
look from a different angle, but boils down to the same fundamental issues.
Points 1/ (OOP nature) and 2/ (non-inheritance of ~this) from my previous
commentator are also discussed there and I gave an example of an "OOP nature"
case that I would like to cross post here for illustration purposes...

Quote:

If we did in fact have virtual destructors like C++, the general rule with
inheritance applies: The derived thing must be usable everywhere the base class
is used. That disallows the removal of attributes on virtual function
overrides:

class C {
   ~this() @safe
}

class D {
   override ~this(); // @system
}

void foo(C c) @safe 
{
   // Destroying D is unsafe, but we can't statically check,
   // because for all we know it is at least a C.
   destroy(c);
}

void main()
{
   foo(new D);
}

--


More information about the Digitalmars-d-bugs mailing list