[Issue 16654] New: hashOf returns different hashes for the same string value

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Nov 1 11:08:00 PDT 2016


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

          Issue ID: 16654
           Summary: hashOf returns different hashes for the same string
                    value
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: dev at nomad.so

The following assert fails:

import std.stdio;
import std.conv;

void main(string[] args)
{
    auto x = 1;

    assert(hashOf(x.to!(string)) == hashOf(x.to!(string)));
}

This is because numeric values of the pointers to the strings are being
included in the hash calculation.

Discussion: http://forum.dlang.org/post/gdtaqdooaknhsmcowgxs@forum.dlang.org

--


More information about the Digitalmars-d-bugs mailing list