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