[Issue 19332] New: hashOf fails for const struct that has non-const toHash & has all fields bitwise-hashable

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 25 09:18:46 UTC 2018


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

          Issue ID: 19332
           Summary: hashOf fails for const struct that has non-const
                    toHash & has all fields bitwise-hashable
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: n8sh.secondary at hotmail.com

Example:

---
struct NotOkay
{
    int canBitwiseHashInts;
    size_t toHash() /* not const */ { return 0; }
}

struct Okay
{
    float cantBitwiseHashFloats;
    size_t toHash() /* not const */ { return 0; }
}

void main()
{
    const okay = Okay.init;
    hashOf(okay); // Compiles but writes a message about the non-callable
toHash.

    const notOkay = NotOkay.init;
    hashOf(notOkay); // Compilation fails!
}
---

--


More information about the Digitalmars-d-bugs mailing list