[LLVMbugs] [Bug 19350] New: Cannot use const std::string as key for unordered_multimap: linking error

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Apr 6 22:26:34 PDT 2014


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

            Bug ID: 19350
           Summary: Cannot use const std::string as key for
                    unordered_multimap: linking error
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: socketpair at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

-DOK : error during linking
without -DOK: success
If I remove 'const' before std::string, both compiled successfully.

Exactly the same with gcc 4.6 :( bug in my head?
===============================
#include <string>

#ifdef OK
#include <unordered_map>
typedef std::unordered_multimap<const std::string, int> Eventmap;
#else
#include <map>
typedef std::multimap<const std::string, int> Eventmap;
#endif

int main(void) {
    Eventmap eventmap;
    eventmap.insert(Eventmap::value_type("answer", 42));
    return 0;
}
===============================
$ clang++ bug.cpp -std=c++11 -Wall -Wextra -O3 -DOK
/tmp/bug-MKvQXI.o: In function
`std::__detail::_Hashtable_iterator<std::pair<std::string const, int>, false,
false> std::_Hashtable<std::string const, std::pair<std::string const, int>,
std::allocator<std::pair<std::string const, int> >,
std::_Select1st<std::pair<std::string const, int> >, std::equal_to<std::string
const>, std::hash<std::string const>, std::__detail::_Mod_range_hashing,
std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy,
false, false, false>::_M_insert<std::pair<std::string const, int>
>(std::pair<std::string const, int>&&, std::integral_constant<bool, false>)':
bug.cpp:(.text._ZNSt10_HashtableIKSsSt4pairIS0_iESaIS2_ESt10_Select1stIS2_ESt8equal_toIS0_ESt4hashIS0_ENSt8__detail18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyELb0ELb0ELb0EE9_M_insertIS2_EENSA_19_Hashtable_iteratorIS2_Lb0ELb0EEEOT_St17integral_constantIbLb0EE[_ZNSt10_HashtableIKSsSt4pairIS0_iESaIS2_ESt10_Select1stIS2_ESt8equal_toIS0_ESt4hashIS0_ENSt8__detail18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyELb0ELb0ELb0EE9_M_insertIS2_EENSA_19_Hashtable_iteratorIS2_Lb0ELb0EEEOT_St17integral_constantIbLb0EE]+0x1ba):
undefined reference to `std::hash<std::string const>::operator()(std::string)
const'
/tmp/bug-MKvQXI.o: In function `std::_Hashtable<std::string const,
std::pair<std::string const, int>, std::allocator<std::pair<std::string const,
int> >, std::_Select1st<std::pair<std::string const, int> >,
std::equal_to<std::string const>, std::hash<std::string const>,
std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash,
std::__detail::_Prime_rehash_policy, false, false, false>::_M_rehash(unsigned
long)':
bug.cpp:(.text._ZNSt10_HashtableIKSsSt4pairIS0_iESaIS2_ESt10_Select1stIS2_ESt8equal_toIS0_ESt4hashIS0_ENSt8__detail18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyELb0ELb0ELb0EE9_M_rehashEm[_ZNSt10_HashtableIKSsSt4pairIS0_iESaIS2_ESt10_Select1stIS2_ESt8equal_toIS0_ESt4hashIS0_ENSt8__detail18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyELb0ELb0ELb0EE9_M_rehashEm]+0x134):
undefined reference to `std::hash<std::string const>::operator()(std::string)
const'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
=============================
$ clang --version
Ubuntu clang version 3.3-5ubuntu4~precise1 (branches/release_33) (based on LLVM
3.3)
Target: x86_64-pc-linux-gnu
Thread model: posix
=============================

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140407/1913d9fc/attachment.html>


More information about the llvm-bugs mailing list