class destructors must be @disabled?

H. S. Teoh hsteoh at quickfur.ath.cx
Wed May 18 18:58:21 UTC 2022


On Wed, May 18, 2022 at 02:35:00PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote:
[...]
> No. Class destructors are for cleaning up non-GC resources. As long as
> you stick to those, you can safely run them.
> 
> Structs that get put into classes have to run their destructors
> properly, otherwise, you will have horrible inconsistencies.
> 
> For instance, I would not want to disable the destruction of a
> RefCounted struct inside a class.
[...]

So if the user runs your program with --DRT-gcopt=cleanup:none and you
happen to have a RefCounted struct inside a GC-allocated class, then
you're screwed?


T

-- 
Three out of two people have difficulties with fractions. -- Dirk Eddelbuettel


More information about the Digitalmars-d-learn mailing list