www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23160] New: template alias parameters can be used to bypass

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

          Issue ID: 23160
           Summary: template alias parameters can be used to bypass escape
                    checks
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

Compile with -preview=dip1000

```
 safe:

struct Forward(alias P)
{
    int* call() { return P; }
}

auto bar(int i)  safe
{
    int* p = &i;
    return Forward!(p)(); // should give an error here
}

void main()
{
    assert(*bar(3).call() == 3);
}
```
the value of `p` wrongly escapes `bar()`.

--
Jun 04 2022