digitalmars.D.bugs - [Issue 16585] New: dmd thinks function returns unique result despite
- via Digitalmars-d-bugs (33/33) Oct 03 2016 https://issues.dlang.org/show_bug.cgi?id=16585
https://issues.dlang.org/show_bug.cgi?id=16585 Issue ID: 16585 Summary: dmd thinks function returns unique result despite mutable indirection in parameter Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Keywords: accepts-invalid Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: ag0aep6g gmail.com ---- int[] fun(long[] arg) pure { return cast(int[]) arg; } void main() { long[] a = [1]; immutable i = fun(a); /* Should be rejected. Only ok when fun(a) is actually unique. */ immutable copy = i.dup; assert(copy == i); /* Passes. */ a[0] = 2; /* Affects the immutable i. */ assert(copy == i); /* Fails now. */ } ---- Possibly related to issue 15862. --
Oct 03 2016