Skip to content

Conversation

@WalterBright
Copy link
Member

With the scope improvements, this restriction is no longer necessary. It'll be tracked analogously to the way static arrays are tracked when a slice is taken.

@mihails-strasuns mihails-strasuns changed the title allow taking address of local in @safe code [scope] allow taking address of local in @safe code Nov 17, 2016
@mihails-strasuns
Copy link

I have tweaked title a bit to avoid possible confusion that this may target master.

Can you please add a test case?

@MartinNowak
Copy link
Member

There are still the @safe failures in phobos that need to get fixed (in dmd!!!).

@mathias-lang-sociomantic
Copy link
Contributor

Also the issue reported here: https://forum.dlang.org/post/mrncdymkdumyqfzlysig@forum.dlang.org

@WalterBright
Copy link
Member Author

There are still the @safe failures in phobos that need to get fixed (in dmd!!!).

It all works on my system. I think the problem is one endemic to having a feature branch - it has diverged.

@MartinNowak
Copy link
Member

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 @safe failures where already in the original return scope PR. Maybe it's indeed a problem with the CI setup for feature branches, will check later today, but I guess it actually has to do with the changes.

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.
Alternatively once can merge dmd@master into dmd@scope to get the latest dmd state.

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.
https://travis-ci.org/dlang/dmd/jobs/178268068#L1076

@MartinNowak
Copy link
Member

Please add some test cases for taking the address in @safe code.

@WalterBright
Copy link
Member Author

Also added test case for taking address of local.

int* q;
scope int* p;
scope int** pp = &q; // ok
pp = &p; // error
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MartinNowak MartinNowak merged commit a98e6ed into dlang:scope Nov 25, 2016
@WalterBright WalterBright deleted the addr-of-local branch November 26, 2016 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants