Boost C++ Libraries: Ticket #7175: Rev 74766 breaks unordered_map on gcc 3.4 https://svn.boost.org/trac10/ticket/7175 <p> 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: </p> <p> ~&gt; gcc --version gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) ... </p> <p> ~&gt; cat regress_unordered.cpp #include &lt;boost/unordered_map.hpp&gt; #include &lt;iostream&gt; </p> <p> int main() { </p> <blockquote> <p> boost::unordered_map&lt;std::string, std::size_t&gt; counts; counts<a class="missing wiki">one</a>++; std::cout &lt;&lt; counts<a class="missing wiki">one</a> &lt;&lt; std::endl; </p> </blockquote> <p> } </p> <p> ~&gt; 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&lt;std::allocator&lt;boost::unordered::detail::ptr_node&lt;std::pair&lt;const std::string, size_t&gt; &gt; &gt; &gt;': /home/luc/Developer/cctbx/boost/boost/unordered/detail/unique.hpp:155: instantiated from `boost::unordered::detail::pick_node&lt;std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt;, std::pair&lt;const std::string, size_t&gt; &gt;' /home/luc/Developer/cctbx/boost/boost/unordered/detail/unique.hpp:202: instantiated from `boost::unordered::detail::map&lt;std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt;, std::string, size_t, boost::hash&lt;std::string&gt;, std::equal_to&lt;std::string&gt; &gt;' /home/luc/Developer/cctbx/boost/boost/unordered/unordered_map.hpp:59: instantiated from `boost::unordered::unordered_map&lt;std::string, size_t, boost::hash&lt;std::string&gt;, std::equal_to&lt;std::string&gt;, std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt; &gt;' regress_unordered.cpp:5: instantiated from here /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp:985: error: <code>template&lt;class T&gt; static typename boost::disable_if_c&lt;( boost::unordered::detail::has_construct&lt;Alloc,T&gt;::value &amp;&amp; boost::is_same&lt;T,typename Alloc::value_type&gt;::value), void&gt;::type boost::unordered::detail::allocator_traits::construct(Alloc&amp;, T*, const T&amp;) [with T = T, Alloc = std::allocator&lt;boost::unordered::detail::ptr_node&lt;std::pair&lt;const std::string, size_t&gt; &gt; &gt;]' and </code>template&lt;class T&gt; static typename boost::enable_if_c&lt;( boost::unordered::detail::has_construct&lt;Alloc,T&gt;::value &amp;&amp; boost::is_same&lt;T,typename Alloc::value_type&gt;::value), void&gt;::type boost::unordered::detail::allocator_traits::construct(Alloc&amp;, T*, const T&amp;) [with T = T, Alloc = std::allocator&lt;boost::unordered::detail::ptr_node&lt;std::pair&lt;const std::string, size_t&gt; &gt; &gt;]' cannot be overloaded /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp:1005: error: <code>template&lt;class T&gt; static typename boost::disable_if_c&lt;( boost::unordered::detail::has_destroy&lt;Alloc,T&gt;::value &amp;&amp; boost::is_same&lt;T,typename Alloc::value_type&gt;::value), void&gt;::type boost::unordered::detail::allocator_traits::destroy(Alloc&amp;, T*) [with T = T, Alloc = std::allocator&lt;boost::unordered::detail::ptr_node&lt;std::pair&lt;const std::string, size_t&gt; &gt; &gt;]' and </code>template&lt;class T&gt; static typename boost::enable_if_c&lt;( boost::unordered::detail::has_destroy&lt;Alloc,T&gt;::value &amp;&amp; boost::is_same&lt;T,typename Alloc::value_type&gt;::value), void&gt;::type boost::unordered::detail::allocator_traits::destroy(Alloc&amp;, T*) [with T = T, Alloc = std::allocator&lt;boost::unordered::detail::ptr_node&lt;std::pair&lt;const std::string, size_t&gt; &gt; &gt;]' cannot be overloaded /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp: In instantiation of `boost::unordered::detail::allocator_traits&lt;std::allocator&lt;boost::unordered::detail::ptr_bucket&gt; &gt;': /home/luc/Developer/cctbx/boost/boost/unordered/detail/unique.hpp:155: instantiated from `boost::unordered::detail::pick_node&lt;std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt;, std::pair&lt;const std::string, size_t&gt; &gt;' /home/luc/Developer/cctbx/boost/boost/unordered/detail/unique.hpp:202: instantiated from `boost::unordered::detail::map&lt;std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt;, std::string, size_t, boost::hash&lt;std::string&gt;, std::equal_to&lt;std::string&gt; &gt;' /home/luc/Developer/cctbx/boost/boost/unordered/unordered_map.hpp:59: instantiated from `boost::unordered::unordered_map&lt;std::string, size_t, boost::hash&lt;std::string&gt;, std::equal_to&lt;std::string&gt;, std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt; &gt;' regress_unordered.cpp:5: instantiated from here /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp:985: error: <code>template&lt;class T&gt; static typename boost::disable_if_c&lt;( boost::unordered::detail::has_construct&lt;Alloc,T&gt;::value &amp;&amp; boost::is_same&lt;T,typename Alloc::value_type&gt;::value), void&gt;::type boost::unordered::detail::allocator_traits::construct(Alloc&amp;, T*, const T&amp;) [with T = T, Alloc = std::allocator&lt;boost::unordered::detail::ptr_bucket&gt;]' and </code>template&lt;class T&gt; static typename boost::enable_if_c&lt;( boost::unordered::detail::has_construct&lt;Alloc,T&gt;::value &amp;&amp; boost::is_same&lt;T,typename Alloc::value_type&gt;::value), void&gt;::type boost::unordered::detail::allocator_traits::construct(Alloc&amp;, T*, const T&amp;) [with T = T, Alloc = std::allocator&lt;boost::unordered::detail::ptr_bucket&gt;]' cannot be overloaded /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp:1005: error: <code>template&lt;class T&gt; static typename boost::disable_if_c&lt;( boost::unordered::detail::has_destroy&lt;Alloc,T&gt;::value &amp;&amp; boost::is_same&lt;T,typename Alloc::value_type&gt;::value), void&gt;::type boost::unordered::detail::allocator_traits::destroy(Alloc&amp;, T*) [with T = T, Alloc = std::allocator&lt;boost::unordered::detail::ptr_bucket&gt;]' and </code>template&lt;class T&gt; static typename boost::enable_if_c&lt;( boost::unordered::detail::has_destroy&lt;Alloc,T&gt;::value &amp;&amp; boost::is_same&lt;T,typename Alloc::value_type&gt;::value), void&gt;::type boost::unordered::detail::allocator_traits::destroy(Alloc&amp;, T*) [with T = T, Alloc = std::allocator&lt;boost::unordered::detail::ptr_bucket&gt;]' cannot be overloaded /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp: In instantiation of `boost::unordered::detail::allocator_traits&lt;std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt; &gt;': /home/luc/Developer/cctbx/boost/boost/unordered/unordered_map.hpp:65: instantiated from `boost::unordered::unordered_map&lt;std::string, size_t, boost::hash&lt;std::string&gt;, std::equal_to&lt;std::string&gt;, std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt; &gt;' regress_unordered.cpp:5: instantiated from here /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp:985: error: <code>template&lt;class T&gt; static typename boost::disable_if_c&lt;( boost::unordered::detail::has_construct&lt;Alloc,T&gt;::value &amp;&amp; boost::is_same&lt;T,typename Alloc::value_type&gt;::value), void&gt;::type boost::unordered::detail::allocator_traits::construct(Alloc&amp;, T*, const T&amp;) [with T = T, Alloc = std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt;]' and </code>template&lt;class T&gt; static typename boost::enable_if_c&lt;( boost::unordered::detail::has_construct&lt;Alloc,T&gt;::value &amp;&amp; boost::is_same&lt;T,typename Alloc::value_type&gt;::value), void&gt;::type boost::unordered::detail::allocator_traits::construct(Alloc&amp;, T*, const T&amp;) [with T = T, Alloc = std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt;]' cannot be overloaded /home/luc/Developer/cctbx/boost/boost/unordered/detail/allocate.hpp:1005: error: <code>template&lt;class T&gt; static typename boost::disable_if_c&lt;( boost::unordered::detail::has_destroy&lt;Alloc,T&gt;::value &amp;&amp; boost::is_same&lt;T,typename Alloc::value_type&gt;::value), void&gt;::type boost::unordered::detail::allocator_traits::destroy(Alloc&amp;, T*) [with T = T, Alloc = std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt;]' and </code>template&lt;class T&gt; static typename boost::enable_if_c&lt;( boost::unordered::detail::has_destroy&lt;Alloc,T&gt;::value &amp;&amp; boost::is_same&lt;T,typename Alloc::value_type&gt;::value), void&gt;::type boost::unordered::detail::allocator_traits::destroy(Alloc&amp;, T*) [with T = T, Alloc = std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt;]' cannot be overloaded /home/luc/Developer/cctbx/boost/boost/unordered/detail/buckets.hpp: In member function `void boost::unordered::detail::buckets&lt;A, Bucket, Node, Policy&gt;::create_buckets() [with A = std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt;, Bucket = boost::unordered::detail::ptr_bucket, Node = boost::unordered::detail::ptr_node&lt;std::pair&lt;const std::string, size_t&gt; &gt;, Policy = boost::unordered::detail::prime_policy&lt;size_t&gt;]': /home/luc/Developer/cctbx/boost/boost/unordered/detail/table.hpp:403: instantiated from `void boost::unordered::detail::table&lt;Types&gt;::reserve_for_insert(size_t) [with Types = boost::unordered::detail::map&lt;std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt;, std::string, size_t, boost::hash&lt;std::string&gt;, std::equal_to&lt;std::string&gt; &gt;]' /home/luc/Developer/cctbx/boost/boost/unordered/detail/unique.hpp:402: instantiated from `typename boost::unordered::detail::table&lt;Types&gt;::value_type&amp; boost::unordered::detail::table_impl&lt;Types&gt;::operator[](const typename boost::unordered::detail::table&lt;Types&gt;::key_type&amp;) [with Types = boost::unordered::detail::map&lt;std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt;, std::string, size_t, boost::hash&lt;std::string&gt;, std::equal_to&lt;std::string&gt; &gt;]' /home/luc/Developer/cctbx/boost/boost/unordered/unordered_map.hpp:1195: instantiated from `typename boost::unordered::unordered_map&lt;K, T, H, P, A&gt;::mapped_type&amp; boost::unordered::unordered_map&lt;K, T, H, P, A&gt;::operator[](const K&amp;) [with K = std::string, T = size_t, H = boost::hash&lt;std::string&gt;, P = std::equal_to&lt;std::string&gt;, A = std::allocator&lt;std::pair&lt;const std::string, size_t&gt; &gt;]' 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&lt;std::allocator&lt;boost::unordered::detail::ptr_node&lt;std::pair&lt;const std::string, size_t&gt; &gt; &gt; &gt;::construct(std::allocator&lt;boost::unordered::detail::ptr_node&lt;std::pair&lt;const std::string, size_t&gt; &gt; &gt;&amp;, boost::unordered::detail::ptr_bucket*, boost::unordered::detail::ptr_bucket)' </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7175 Trac 1.4.3 anonymous Wed, 25 Jul 2012 16:22:30 GMT <link>https://svn.boost.org/trac10/ticket/7175#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7175#comment:1</guid> <description> <p> I got the formatting of the snippet wrong, sorry: </p> <pre class="wiki">#include &lt;boost/unordered_map.hpp&gt; #include &lt;iostream&gt; int main() { boost::unordered_map&lt;std::string, std::size_t&gt; counts; counts["one"]++; std::cout &lt;&lt; counts["one"] &lt;&lt; std::endl; } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Daniel James</dc:creator> <pubDate>Thu, 26 Jul 2012 21:48:36 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/7175#comment:2 https://svn.boost.org/trac10/ticket/7175#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> 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? </p> Ticket Daniel James Thu, 26 Jul 2012 22:28:44 GMT <link>https://svn.boost.org/trac10/ticket/7175#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7175#comment:3</guid> <description> <p> Oops, forgot to tag the commit. It's <a class="changeset" href="https://svn.boost.org/trac10/changeset/79762" title="Unordered: Use a SFINAE parameter rather than return type for C++03 ...">[79762]</a>. </p> </description> <category>Ticket</category> </item> <item> <author>luc_j_bourhis@…</author> <pubDate>Fri, 27 Jul 2012 07:47:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7175#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7175#comment:4</guid> <description> <p> I can confirm that rev 79762 fixed the problem I reported. Thanks a bunch! </p> <p> For the record, the project on the behalf of which I prepared the bug report (Phenix, <a class="ext-link" href="http://www.phenix-online.org"><span class="icon">​</span>http://www.phenix-online.org</a>) is actively trying to move to gcc &gt; 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. </p> <p> Thanks again! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Daniel James</dc:creator> <pubDate>Sun, 05 Aug 2012 08:34:50 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7175#comment:5 https://svn.boost.org/trac10/ticket/7175#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/79868" title="Unordered: Merge from trunk - Avoid an incorrect MSVC unused variable ...">[79868]</a>) Unordered: Merge from trunk </p> <ul><li>Avoid an incorrect MSVC unused variable warning in the tests. </li><li>Remove a <code>try..catch</code>. </li><li>Adjust SFINAE use to try to supprt g++ 3.4. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7175" title="#7175: Bugs: Rev 74766 breaks unordered_map on gcc 3.4 (closed: fixed)">#7175</a>. </li><li>Fix some use of rvalues. </li><li>Extra info in <code>at_tests</code>. </li></ul> Ticket