[Issue 12910] New: [AA] `rehash` is incorrectly inferred as strongly pure for some associative arrays

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jun 13 02:20:51 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12910

          Issue ID: 12910
           Summary: [AA] `rehash` is incorrectly inferred as strongly pure
                    for some associative arrays
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: verylonglogin.reg at gmail.com

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
---

--


More information about the Digitalmars-d-bugs mailing list