http://d.puremagic.com/issues/show_bug.cgi?id=10758
Summary: Unsound type checking for inout.
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: [email protected]
ReportedBy: [email protected]
--- Comment #0 from [email protected] 2013-08-04 16:01:37 PDT ---
With DMD, inout can be used to coerce away immutability as follows:
int* foo(inout(int)* x)@safe{
inout(int)* screwUp(inout(int)*){ return x; }
return screwUp((int*).init);
}
void main(){
immutable x = 123;
static assert(is(typeof(*&x)==immutable));
assert(*&x==123);
immutable(int)* y = &x;
*foo(y)=456;
assert(*&x==456);
assert(x!=*&x); // (!)
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------