digitalmars.D.bugs - [Issue 15862] New: dmd thinks functions are strongly pure despite
- via Digitalmars-d-bugs (38/38) Apr 01 2016 https://issues.dlang.org/show_bug.cgi?id=15862
https://issues.dlang.org/show_bug.cgi?id=15862 Issue ID: 15862 Summary: dmd thinks functions are strongly pure despite mutable indirections in the return type Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: wrong-code Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: ag0aep6g gmail.com dmd thinks functions are strongly pure despite mutable indirections in the return type ---- int* p() pure nothrow {return new int;} int[] a() pure nothrow {return [0];} Object o() pure nothrow {return new Object;} void main() { int* p1 = p(); int* p2 = p(); if (p1 is p2) throw new Exception("pointers same"); int[] a1 = a(); int[] a2 = a(); if (a1 is a2) throw new Exception("arrays same"); Object o1 = o(); Object o2 = o(); if (o1 is o2) throw new Exception("objects same"); } ---- No exceptions should be thrown. All is fine when compiled without optimization flags. When compiled with `dmd -O -release`, the exceptions are thrown. ldc does not seem to have the same issue. --
Apr 01 2016