[scope] allow taking address of local in @safe code#6253
[scope] allow taking address of local in @safe code#6253MartinNowak merged 5 commits intodlang:scopefrom
Conversation
|
I have tweaked title a bit to avoid possible confusion that this may target master. Can you please add a test case? |
|
There are still the |
|
Also the issue reported here: https://forum.dlang.org/post/mrncdymkdumyqfzlysig@forum.dlang.org |
It all works on my system. I think the problem is one endemic to having a feature branch - it has diverged. |
That's a premature conclusion, the Regarding diversion, our setup also supports identically named feature branches in druntime/phobos, that can be used to avoid phobos from getting out of sync, or for features that need compiler and library changes. I wouldn't know which safety related changes would cause such phobos error, unless sth. got merged into dmd@master that actually belonged into dmd@scope. |
|
Please add some test cases for taking the address in |
|
Also added test case for taking address of local. |
| int* q; | ||
| scope int* p; | ||
| scope int** pp = &q; // ok | ||
| pp = &p; // error |
There was a problem hiding this comment.
The lifetime of pp is shorter than the lifetime of p, so shouldn't this be allowed?
We could go with a conservative implemenation for now.
There was a problem hiding this comment.
You're right. I'll file an enhancement request.
There was a problem hiding this comment.
With the
scopeimprovements, this restriction is no longer necessary. It'll be tracked analogously to the way static arrays are tracked when a slice is taken.