[Issue 6912] New: non-transitivity of inout breaks const system
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Nov 8 16:04:11 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6912
Summary: non-transitivity of inout breaks const system
Product: D
Version: D2
Platform: Other
OS/Version: All
Status: NEW
Severity: critical
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: timon.gehr at gmx.ch
--- Comment #0 from timon.gehr at gmx.ch 2011-11-08 16:03:34 PST ---
Consider:
int[] y;
inout(const(int)[]) foo(inout(int) x){
y=new int[10];
const(int)[] q = y;
inout a = q;
return a;
}
void main(){
immutable int x;
immutable int[] oops = foo(x);
assert(is(typeof(oops[0]) == immutable));
auto oldoops_0 = oops[0];
y[0]++;
assert(oops[0] != oldoops_0);
}
This is caused by the fact that !is(inout(const(int)[])==inout(int[])), i.e.
inout is currently non-transitive in certain cases and making it 'override'
const transitively will fix the issue.
--
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