Bug 17744 – Type system hole: returning inout delegates

Status
NEW
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-08-11T15:41:13Z
Last change time
2024-12-13T18:54:01Z
Keywords
safe
Assigned to
No Owner
Creator
timon.gehr
Moved to GitHub: dmd#19300 →

Comments

Comment #0 by timon.gehr — 2017-08-11T15:41:13Z
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`).
Comment #1 by robert.schadek — 2024-12-13T18:54:01Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19300 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB