[LLVMbugs] [Bug 13726] New: HashString implements Bernstein hash using signed char, instead of traditional unsigned char

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Aug 29 11:55:01 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13726

             Bug #: 13726
           Summary: HashString implements Bernstein hash using signed
                    char, instead of traditional unsigned char
           Product: new-bugs
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: willdtz at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


HashString() in include/llvm/ADT/StringExtras.h has comments saying it
implements the Bernstein hash function.

However, all posted implementations of this hash (including the one at the URL
mentioned in the source) that I can find define it in terms of unsigned char's,
not the signed ones that the current implementation uses.

This causes the HashString function to produce different hashes for strings
containing characters >= 128.

I have not experimented to see the effects "fixing" this would have, but it
seems that we should either use the algorithm as posted or have a reason for
deviating (mentioned in the source).

HashString is used by code like StringMap, FWIW.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list