[Issue 8295] Struct member destructor can not be called from shared struct instance

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 12 16:09:44 UTC 2018


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

--- Comment #7 from anonymous4 <dfj1esp02 at sneakemail.com> ---
(In reply to weaselcat from comment #4)
> on topic:
> a shared destructor doesn't really make sense at all, shouldn't shared
> objects just have unshared destructors?
It means implicit cast from shared to unshared, which required uniqueness,
which can't be guaranteed by compiler, so such implicit cast is unsafe. Another
classic example is reference counted data that needs to know whether it's
shared or not and use atomic arithmetic when needed.
Examples above should be rejected at compile time, because they assume the
unshared destructor is safe to call on shared data, which is against the design
of shared: sharing must be opt-in.

--


More information about the Digitalmars-d-bugs mailing list