[Issue 10758] New: Unsound type checking for inout.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 4 16:01:38 PDT 2013
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: nobody at puremagic.com
ReportedBy: timon.gehr at gmx.ch
--- Comment #0 from timon.gehr at gmx.ch 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: -------
More information about the Digitalmars-d-bugs
mailing list