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

Dennis <dkor...@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |dkor...@live.nl
         Resolution|WORKSFORME                  |---

--- Comment #2 from Dennis <dkor...@live.nl> ---
(In reply to moonlightsentinel from comment #1)
> Works fine with current master:
> 
> ----------------------------------------------
> @safe int** foo(ref scope int* x)
> {
>   int** a = &x;
>   return a;
> }

That only works because `x` is a `scope` pointer, and the compiler can't give
double `scope` to it when taking its address. The original example of a
non-scope ref still compiles:

```
@safe:
int* foo(ref int x) {
    int* a = &x;
    return a;
}


void main() {
    int* ptr;
    {
        int x;
        ptr = foo(x);
    }
    // x escaped via ptr here
}
```

--

Reply via email to