Modify

Ticket #7175 (closed Bugs: fixed)

Opened 21 months ago

Last modified 21 months ago

Rev 74766 breaks unordered_map on gcc 3.4

Reported by: luc_j_bourhis@… Owned by: danieljames
Milestone: To Be Determined Component: unordered
Version: Boost 1.50.0 Severity: Problem
Keywords: Cc:

Description

I was initially confronted to that bug with 1.50 and then I pinpointed the first bad rev using git bisect. Here is how to reproduce the problem:

~> gcc --version gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) ...

~> cat regress_unordered.cpp #include <boost/unordered_map.hpp> #include <iostream>

int main() {

boost::unordered_map<std::string, std::size_t> counts; countsone?++; std::cout << countsone? << std::endl;

}

~> g++ -c regress_unordered.cpp -I/path/to/boost /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp: In instantiation of `boost::unordered::detail::allocator_traits<std::allocator<boost::unordered::detail::ptr_node<std::pair<const std::string, size_t> > > >': /home/luc/Developer/cctbx/boost/boost/unordered/detail/unique.hpp:155: instantiated from `boost::unordered::detail::pick_node<std::allocator<std::pair<const std::string, size_t> >, std::pair<const std::string, size_t> >' /home/luc/Developer/cctbx/boost/boost/unordered/detail/unique.hpp:202: instantiated from `boost::unordered::detail::map<std::allocator<std::pair<const std::string, size_t> >, std::string, size_t, boost::hash<std::string>, std::equal_to<std::string> >' /home/luc/Developer/cctbx/boost/boost/unordered/unordered_map.hpp:59: instantiated from `boost::unordered::unordered_map<std::string, size_t, boost::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<const std::string, size_t> > >' regress_unordered.cpp:5: instantiated from here /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp:985: error: template<class T> static typename boost::disable_if_c<( boost::unordered::detail::has_construct<Alloc,T>::value && boost::is_same<T,typename Alloc::value_type>::value), void>::type boost::unordered::detail::allocator_traits::construct(Alloc&, T*, const T&) [with T = T, Alloc = std::allocator<boost::unordered::detail::ptr_node<std::pair<const std::string, size_t> > >]' and template<class T> static typename boost::enable_if_c<( boost::unordered::detail::has_construct<Alloc,T>::value && boost::is_same<T,typename Alloc::value_type>::value), void>::type boost::unordered::detail::allocator_traits::construct(Alloc&, T*, const T&) [with T = T, Alloc = std::allocator<boost::unordered::detail::ptr_node<std::pair<const std::string, size_t> > >]' cannot be overloaded /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp:1005: error: template<class T> static typename boost::disable_if_c<( boost::unordered::detail::has_destroy<Alloc,T>::value && boost::is_same<T,typename Alloc::value_type>::value), void>::type boost::unordered::detail::allocator_traits::destroy(Alloc&, T*) [with T = T, Alloc = std::allocator<boost::unordered::detail::ptr_node<std::pair<const std::string, size_t> > >]' and template<class T> static typename boost::enable_if_c<( boost::unordered::detail::has_destroy<Alloc,T>::value && boost::is_same<T,typename Alloc::value_type>::value), void>::type boost::unordered::detail::allocator_traits::destroy(Alloc&, T*) [with T = T, Alloc = std::allocator<boost::unordered::detail::ptr_node<std::pair<const std::string, size_t> > >]' cannot be overloaded /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp: In instantiation of `boost::unordered::detail::allocator_traits<std::allocator<boost::unordered::detail::ptr_bucket> >': /home/luc/Developer/cctbx/boost/boost/unordered/detail/unique.hpp:155: instantiated from `boost::unordered::detail::pick_node<std::allocator<std::pair<const std::string, size_t> >, std::pair<const std::string, size_t> >' /home/luc/Developer/cctbx/boost/boost/unordered/detail/unique.hpp:202: instantiated from `boost::unordered::detail::map<std::allocator<std::pair<const std::string, size_t> >, std::string, size_t, boost::hash<std::string>, std::equal_to<std::string> >' /home/luc/Developer/cctbx/boost/boost/unordered/unordered_map.hpp:59: instantiated from `boost::unordered::unordered_map<std::string, size_t, boost::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<const std::string, size_t> > >' regress_unordered.cpp:5: instantiated from here /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp:985: error: template<class T> static typename boost::disable_if_c<( boost::unordered::detail::has_construct<Alloc,T>::value && boost::is_same<T,typename Alloc::value_type>::value), void>::type boost::unordered::detail::allocator_traits::construct(Alloc&, T*, const T&) [with T = T, Alloc = std::allocator<boost::unordered::detail::ptr_bucket>]' and template<class T> static typename boost::enable_if_c<( boost::unordered::detail::has_construct<Alloc,T>::value && boost::is_same<T,typename Alloc::value_type>::value), void>::type boost::unordered::detail::allocator_traits::construct(Alloc&, T*, const T&) [with T = T, Alloc = std::allocator<boost::unordered::detail::ptr_bucket>]' cannot be overloaded /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp:1005: error: template<class T> static typename boost::disable_if_c<( boost::unordered::detail::has_destroy<Alloc,T>::value && boost::is_same<T,typename Alloc::value_type>::value), void>::type boost::unordered::detail::allocator_traits::destroy(Alloc&, T*) [with T = T, Alloc = std::allocator<boost::unordered::detail::ptr_bucket>]' and template<class T> static typename boost::enable_if_c<( boost::unordered::detail::has_destroy<Alloc,T>::value && boost::is_same<T,typename Alloc::value_type>::value), void>::type boost::unordered::detail::allocator_traits::destroy(Alloc&, T*) [with T = T, Alloc = std::allocator<boost::unordered::detail::ptr_bucket>]' cannot be overloaded /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp: In instantiation of `boost::unordered::detail::allocator_traits<std::allocator<std::pair<const std::string, size_t> > >': /home/luc/Developer/cctbx/boost/boost/unordered/unordered_map.hpp:65: instantiated from `boost::unordered::unordered_map<std::string, size_t, boost::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<const std::string, size_t> > >' regress_unordered.cpp:5: instantiated from here /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp:985: error: template<class T> static typename boost::disable_if_c<( boost::unordered::detail::has_construct<Alloc,T>::value && boost::is_same<T,typename Alloc::value_type>::value), void>::type boost::unordered::detail::allocator_traits::construct(Alloc&, T*, const T&) [with T = T, Alloc = std::allocator<std::pair<const std::string, size_t> >]' and template<class T> static typename boost::enable_if_c<( boost::unordered::detail::has_construct<Alloc,T>::value && boost::is_same<T,typename Alloc::value_type>::value), void>::type boost::unordered::detail::allocator_traits::construct(Alloc&, T*, const T&) [with T = T, Alloc = std::allocator<std::pair<const std::string, size_t> >]' cannot be overloaded /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp:1005: error: template<class T> static typename boost::disable_if_c<( boost::unordered::detail::has_destroy<Alloc,T>::value && boost::is_same<T,typename Alloc::value_type>::value), void>::type boost::unordered::detail::allocator_traits::destroy(Alloc&, T*) [with T = T, Alloc = std::allocator<std::pair<const std::string, size_t> >]' and template<class T> static typename boost::enable_if_c<( boost::unordered::detail::has_destroy<Alloc,T>::value && boost::is_same<T,typename Alloc::value_type>::value), void>::type boost::unordered::detail::allocator_traits::destroy(Alloc&, T*) [with T = T, Alloc = std::allocator<std::pair<const std::string, size_t> >]' cannot be overloaded /home/luc/Developer/cctbx/boost/boost/unordered/detail/buckets.hpp: In member function `void boost::unordered::detail::buckets<A, Bucket, Node, Policy>::create_buckets() [with A = std::allocator<std::pair<const std::string, size_t> >, Bucket = boost::unordered::detail::ptr_bucket, Node = boost::unordered::detail::ptr_node<std::pair<const std::string, size_t> >, Policy = boost::unordered::detail::prime_policy<size_t>]': /home/luc/Developer/cctbx/boost/boost/unordered/detail/table.hpp:403: instantiated from `void boost::unordered::detail::table<Types>::reserve_for_insert(size_t) [with Types = boost::unordered::detail::map<std::allocator<std::pair<const std::string, size_t> >, std::string, size_t, boost::hash<std::string>, std::equal_to<std::string> >]' /home/luc/Developer/cctbx/boost/boost/unordered/detail/unique.hpp:402: instantiated from `typename boost::unordered::detail::table<Types>::value_type& boost::unordered::detail::table_impl<Types>::operator[](const typename boost::unordered::detail::table<Types>::key_type&) [with Types = boost::unordered::detail::map<std::allocator<std::pair<const std::string, size_t> >, std::string, size_t, boost::hash<std::string>, std::equal_to<std::string> >]' /home/luc/Developer/cctbx/boost/boost/unordered/unordered_map.hpp:1195: instantiated from `typename boost::unordered::unordered_map<K, T, H, P, A>::mapped_type& boost::unordered::unordered_map<K, T, H, P, A>::operator[](const K&) [with K = std::string, T = size_t, H = boost::hash<std::string>, P = std::equal_to<std::string>, A = std::allocator<std::pair<const std::string, size_t> >]' regress_unordered.cpp:6: instantiated from here /home/luc/Developer/cctbx/boost/boost/unordered/detail/buckets.hpp:726: error: no matching function for call to `boost::unordered::detail::allocator_traits<std::allocator<boost::unordered::detail::ptr_node<std::pair<const std::string, size_t> > > >::construct(std::allocator<boost::unordered::detail::ptr_node<std::pair<const std::string, size_t> > >&, boost::unordered::detail::ptr_bucket*, boost::unordered::detail::ptr_bucket)'

Attachments

Change History

comment:1 Changed 21 months ago by anonymous

I got the formatting of the snippet wrong, sorry:

#include <boost/unordered_map.hpp>
#include <iostream>

int main() {
      boost::unordered_map<std::string, std::size_t> counts;
      counts["one"]++;
      std::cout << counts["one"] << std::endl;
}

comment:2 Changed 21 months ago by danieljames

  • Status changed from new to assigned

I don't really support anything earlier than gcc 4.0 nowadays, but I'll try to fix this in trunk soon. I made a similar change to boost::hash recently for integers, so can you try running the hash regression tests?

comment:3 Changed 21 months ago by danieljames

Oops, forgot to tag the commit. It's [79762].

comment:4 Changed 21 months ago by luc_j_bourhis@…

I can confirm that rev 79762 fixed the problem I reported. Thanks a bunch!

For the record, the project on the behalf of which I prepared the bug report (Phenix,  http://www.phenix-online.org) is actively trying to move to gcc > 4.0 as well but some clients are stuck with gcc 3.4. Thanks to you, they get some more mileage while we can work with a recent Boost version, and therefore avoid issues at the other end of the spectrum with the latest compiler releases.

Thanks again!

comment:5 Changed 21 months ago by danieljames

  • Status changed from assigned to closed
  • Resolution set to fixed

(In [79868]) Unordered: Merge from trunk

  • Avoid an incorrect MSVC unused variable warning in the tests.
  • Remove a try..catch.
  • Adjust SFINAE use to try to supprt g++ 3.4. Fixes #7175.
  • Fix some use of rvalues.
  • Extra info in at_tests.
View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.