Bug 10063 – inout+pure results in ability to produce immutable reference to mutable data

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-10T18:12:00Z
Last change time
2013-05-18T08:11:53Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
verylonglogin.reg

Comments

Comment #0 by verylonglogin.reg — 2013-05-10T18:12:50Z
This code compiles but shouldn't: --- inout(void)* f(inout void* p) pure { return p; } immutable(void)* g(inout int* p) pure { return f(p); } --- Explicit or implicit cast is required for this issue to appear. Change `g` to accept `void*` instead of `int*` to see expected compilation error. Another test-case: --- struct S { uint* p; inout(void)* f() pure inout { return p; } immutable(void)* g() pure inout { return f(); } } ---
Comment #1 by github-bugzilla — 2013-05-13T07:46:50Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/0dc34e8bf8dcbb7a16f4de197b902e83cbb21306 fix Issue 10063 - inout+pure results in ability to produce immutable reference to mutable data https://github.com/D-Programming-Language/dmd/commit/3d7f0374d99f94307e5dd3694594ac3b172ecbae Merge pull request #2031 from 9rnsr/fix10063 Issue 10063 - inout+pure results in ability to produce immutable reference to mutable data
Comment #2 by k.hara.pg — 2013-05-18T08:11:53Z