[Bug libstdc++/92770] New: std::unordered_map<T, U> requires both T and U to be fully declared
raphael.kubo.da.costa at intel dot com
gcc-bugzilla@gcc.gnu.org
Tue Dec 3 13:53:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92770
Bug ID: 92770
Summary: std::unordered_map<T, U> requires both T and U to be
fully declared
Product: gcc
Version: 9.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: raphael.kubo.da.costa at intel dot com
Target Milestone: ---
$ cat unordered_map.cc
#include <unordered_map>
struct S;
class C {
std::unordered_map<S, int> map_;
};
$ g++ -std=gnu++14 -c unordered_map.cc
In file included from /usr/include/c++/9/unordered_map:43,
from unordered_map.cc:1:
/usr/include/c++/9/bits/stl_pair.h: In instantiation of ‘struct std::pair<const
S, int>’:
/usr/include/c++/9/ext/aligned_buffer.h:91:28: required from ‘struct
__gnu_cxx::__aligned_buffer<std::pair<const S, int> >’
/usr/include/c++/9/bits/hashtable_policy.h:233:43: required from ‘struct
std::__detail::_Hash_node_value_base<std::pair<const S, int> >’
/usr/include/c++/9/bits/hashtable_policy.h:264:12: required from ‘struct
std::__detail::_Hash_node<std::pair<const S, int>, true>’
/usr/include/c++/9/bits/hashtable_policy.h:2027:13: required from ‘struct
std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<const
S, int>, true> > >’
/usr/include/c++/9/bits/hashtable.h:173:11: required from ‘class
std::_Hashtable<S, std::pair<const S, int>, std::allocator<std::pair<const S,
int> >, std::__detail::_Select1st, std::equal_to<S>, std::hash<S>,
std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash,
std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true,
false, true> >’
/usr/include/c++/9/bits/unordered_map.h:105:18: required from ‘class
std::unordered_map<S, int>’
unordered_map.cc:4:30: required from here
/usr/include/c++/9/bits/stl_pair.h:214:11: error: ‘std::pair<_T1, _T2>::first’
has incomplete type
214 | _T1 first; /// @c first is a copy of the first
object
| ^~~~~
unordered_map.cc:2:8: note: forward declaration of ‘struct S’
2 | struct S;
|
The excerpt above works fine with libc++ and MSVC's STL.
More information about the Gcc-bugs
mailing list