LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 41876 - std::hash should not accept std::basic_strings with custom character traits
Summary: std::hash should not accept std::basic_strings with custom character traits
Status: RESOLVED FIXED
Alias: None
Product: libc++
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: 8.0
Hardware: PC Linux
: P normal
Assignee: Zoe Carver
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-14 10:11 PDT by marc
Modified: 2019-05-20 14:57 PDT (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description marc 2019-05-14 10:11:30 PDT
libc++ provides a specialization of std::hash that works for arbitrary instantiations of std::basic_string.  This can produce incorrect behavior for basic_string instantiations with custom character traits that override equality (e.g. traits for case-insensitive comparison).  Since the standard only requires that hash for for the typedefed instantiations (e.g. hash<string>, hash<wstring>, etc), libc++ should not support hashing basic_strings with custom character traits to avoid incorrect behavior.
Comment 1 Zoe Carver 2019-05-15 10:33:31 PDT
Good catch. My fix is up for review here: https://reviews.llvm.org/D61954
Comment 2 Marshall Clow (home) 2019-05-20 14:57:35 PDT
Fixed in revision 361201