<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Cannot use const std::string as key for unordered_multimap: linking error"
href="http://llvm.org/bugs/show_bug.cgi?id=19350">19350</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Cannot use const std::string as key for unordered_multimap: linking error
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.3
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>socketpair@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>-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>
<span class="quote">>(std::pair<std::string const, int>&&, std::integral_constant<bool, false>)':</span >
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
=============================</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>