www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16654] New: hashOf returns different hashes for the same


          Issue ID: 16654
           Summary: hashOf returns different hashes for the same string
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: dev 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

Nov 01 2016