[Issue 22782] [dip1000] address of ref can be assigned to non-scope parameter

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 16 20:42:28 UTC 2022


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

Dennis <dkorpel at live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |safe, Vision
                 CC|                            |dkorpel at live.nl
           Hardware|x86_64                      |All
            Summary|[dip1000] string escaped by |[dip1000] address of ref
                   |throwing constructor        |can be assigned to
                   |                            |non-scope parameter
                 OS|Linux                       |All

--- Comment #2 from Dennis <dkorpel at live.nl> ---
This isn't about constructors or exceptions, it reduces to:

```
@safe:
void fun(ref int x) 
{
    int* scopePtr = &x; // correctly inferred scope
    escape(scopePtr); // correctly rejected

    escape(&x); // accepts invalid
}

int* gPtr;
void escape(int* ptr) {
    gPtr = ptr;
}
```

My fix for issue 12812 (https://github.com/dlang/dmd/pull/12812) was not tested
thoroughly enough, I will look into it.

--


More information about the Digitalmars-d-bugs mailing list