Bug 23160 – template alias parameters can be used to bypass escape checks

Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-06-05T04:54:32Z
Last change time
2022-06-05T09:48:48Z
Keywords
safe
Assigned to
No Owner
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=23112

Comments

Comment #0 by bugzilla — 2022-06-05T04:54:32Z
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()`.
Comment #1 by bugzilla — 2022-06-05T09:48:48Z
This is wrong.