Bug 12910 – [AA] `rehash` is incorrectly inferred as strongly pure for some associative arrays

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-06-13T09:20:00Z
Last change time
2014-06-14T15:37:15Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
verylonglogin.reg
Depends on
12909

Comments

Comment #0 by verylonglogin.reg — 2014-06-13T09:20:51Z
Because of Issue 12909 `rehash` is incorrectly inferred as strongly pure for an associative array with key of non-mutable array or pointer. As a result it can be discarded by an optimizer and also breaks compilation of this code with `-w` ("warnings as errors" ) switch: --- const(int[])[int] aa; auto f(){ return aa; } // to make r-value void main() { f().rehash(); } --- main.d(6): Warning: calling object.rehash!(const(int[])[int], const(int[]), int).rehash without side effects discards return value of type const(int[])[int], prepend a cast(void) if intentional ---
Comment #1 by k.hara.pg — 2014-06-14T12:01:14Z
Comment #2 by github-bugzilla — 2014-06-14T15:37:14Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/fd44afb7d8735a67be48ea4496fabda03166f2fc fix Issue 12910 - [AA] `rehash` is incorrectly inferred as strongly pure for some associative arrays https://github.com/D-Programming-Language/dmd/commit/27fc0660064d0ba0acc34081165e806d8afec8f2 Merge pull request #3667 from 9rnsr/fix12909 Issue 12909 & 12910 - fix purity level calculation for AA parameter