Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2008-04-18 06:27:50


Author: danieljames
Date: 2008-04-18 06:27:50 EDT (Fri, 18 Apr 2008)
New Revision: 44536
URL: http://svn.boost.org/trac/boost/changeset/44536

Log:
Check that hash_table_impl::swap isn't swapping with itself - which is causing the buffered functions to be set with the same value twice, resulting in an assertion.
Text files modified:
   branches/unordered/trunk/boost/unordered/detail/hash_table_impl.hpp | 7 +++++++
   1 files changed, 7 insertions(+), 0 deletions(-)

Modified: branches/unordered/trunk/boost/unordered/detail/hash_table_impl.hpp
==============================================================================
--- branches/unordered/trunk/boost/unordered/detail/hash_table_impl.hpp (original)
+++ branches/unordered/trunk/boost/unordered/detail/hash_table_impl.hpp 2008-04-18 06:27:50 EDT (Fri, 18 Apr 2008)
@@ -1284,6 +1284,13 @@
 
             void swap(BOOST_UNORDERED_TABLE& x)
             {
+ // The swap code can work when swapping a container with itself
+ // but it triggers an assertion in buffered_functions.
+ // At the moment, I'd rather leave that assertion in and add a
+ // check here, rather than remove the assertion. I might change
+ // this at a later date.
+ if(this == &x) return;
+
                 // These can throw, but they only affect the function objects
                 // that aren't in use so it is strongly exception safe, via.
                 // double buffering.


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk