[Issue 17869] scope class object no longer deleted when created via factory function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 9 22:08:56 UTC 2017


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

--- Comment #4 from Rainer Schuetze <r.sagitario at gmx.de> ---
I'm not convinced:

> It's was destroyed twice formerly, destruction was never supposed to run for GC allocated classes.

Sure it has been unsafe so far, just like writing "scope(exit) delete obj;"
twice.

> Scope class always referred to RAII allocated classes on the stack.

Yes, but the spec does not say this explicitly about scope declarations.

> The fact that you can assign heap allocated instances to variables with scope
> storage was unfortunately a bug, as was the double destruction of scope class 
> instances assigned to other scope references.

So why is it now silently accepted? 

BTW: Even std.datetime.timezone still uses scope with factory functions,
relying on GC caused bugs in LDC due to premature collection.

I'm not against changing the meaning of scope for the sake of DIP1000, but I
wonder why it's ok in this case to break code without any warning that worked
fine before.

--


More information about the Digitalmars-d-bugs mailing list