-
-
Notifications
You must be signed in to change notification settings - Fork 668
[scope] allow taking address of local in @safe code #6253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I'll file an enhancement request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.