dip1000 and preview in combine to cause extra safety errors

Nick Treleaven nick at geany.org
Thu Jun 9 20:37:17 UTC 2022


On Thursday, 9 June 2022 at 15:30:47 UTC, Steven Schveighoffer 
wrote:
> What is not OK is the compiler turning actual requests for GC 
> allocation into stack allocations based on that. At this point, 
> it's a literal, but if it did this for e.g. `new T`, we are in 
> for a lot of trouble.

scope has to have a strong guarantee to be meaningful. Why use 
scope in @system code if it was ignored by the compiler? The 
optimization should be allowed.

> I'll ask, is it undefined behavior to return a scope pointer as 
> a non-scope pointer? If so, should we make UB so easy to do?

We shouldn't, but we can't detect all cases of wrong use of scope 
in general in @system code. We do need a warning in the scope 
docs though.

...
> In any case, I filed a bugzilla issue: 
> https://issues.dlang.org/show_bug.cgi?id=23175

Thanks for finding this. I think the problem is changing the 
meaning of `in` in @system code. If `in` is to mean scope too 
then a deprecation period is needed to weed out any uses of `in` 
in @system code. (`in` meaning scope too in @safe code is fine).






More information about the Digitalmars-d mailing list