[Issue 15246] Destructor inheritance doesn't inherit attributes properly

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Oct 27 04:14:28 PDT 2015


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

--- Comment #5 from Andrei Alexandrescu <andrei at erdani.com> ---
(In reply to Marco Leise from comment #4)
> The destructors do *neither* inherit *nor* call their parent destructors.
> Not as a matter of terminology, but because in D they are not called
> recursively, but in sequence, starting from the runtime type's dtor and
> working its way up the inheritance chain. Take a look at the druntime source
> I linked above and you will understand what happens.
> 
> To make the bug report valid we would have to introduce destructor
> inheritance to the language to begin with. Right now the only functions
> affected by the destructor attributes would be the attribute-less
> external(C) functions `rt_finalize` and `rt_finalize2`. (In client code we
> call `rt_finalize` as `destroy(Object obj)` for deterministic object
> destruction).

I understand what happens technically (each dtor is distinct, and code external
to the destructor calls them all).

What happens conceptually is that destructors in derived classes both override
and call destructors in base classes. There is no need to change the language
to make the bug report valid. Destructors must typecheck as if they override
and call the base class destructors.

--


More information about the Digitalmars-d-bugs mailing list