[Issue 17744] New: Type system hole: returning inout delegates
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Aug 11 08:41:13 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17744
Issue ID: 17744
Summary: Type system hole: returning inout delegates
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: critical
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: timon.gehr at gmx.ch
DMD v2.075.0:
@safe:
int a;
immutable(int) b=2;
inout(int)* delegate(inout(int)*)@safe delegate()@safe foo(inout(int)* y){
inout(int)* bar(inout(int)* p){
return y;
}
return ()=>&bar;
}
void main(){
int* y=foo(&b)()(&a);
*y=3;
assert(&b is y); // passes. ouch.
assert(b is *&b); // fails!
}
If &bar is returned directly instead of ()=>&bar, DMD applies a strange
work-around (it replaces `inout` in the returned delegate by `const`).
--
More information about the Digitalmars-d-bugs
mailing list