[Issue 17449] [DIP1000] crash due to covariant conversion of scope delegate to delegate

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 11 08:53:25 UTC 2018


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

--- Comment #4 from Walter Bright <bugzilla at digitalmars.com> ---
(In reply to Rainer Schuetze from comment #3)
> Are you saying that it is ok that adding -dip1000 can change code gen so
> that it crashes?

Yes. This is because 'scope' for delegates now means something with dip1000, it
means the delegate must not escape. If it does, and this is not checked for in
non- at safe functions, it will likely crash.


> I don't see anything unsafe and invalid in the original code. Could you
> elaborate? Please note that it it also in the dmd test suite.

The problem is the delegate escapes from its stack frame, and no closure was
allocated.

The scope checking with delegates is a backwards compatibility thing, as people
often pass scope delegates to non-scope delegate parameters.

--


More information about the Digitalmars-d-bugs mailing list