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: nob...@puremagic.com Reporter: ag0ae...@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. --