Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85999 - trunk/libs/container/test
From: igaztanaga_at_[hidden]
Date: 2013-09-29 07:39:34


Author: igaztanaga
Date: 2013-09-29 07:39:34 EDT (Sun, 29 Sep 2013)
New Revision: 85999
URL: http://svn.boost.org/trac/boost/changeset/85999

Log:
Fixed error in default_init_allocator, it should not construct objects, only allocate raw memory.

Text files modified:
   trunk/libs/container/test/static_vector_test.cpp | 8 --------
   trunk/libs/container/test/vector_test.hpp | 10 +++++-----
   2 files changed, 5 insertions(+), 13 deletions(-)

Modified: trunk/libs/container/test/static_vector_test.cpp
==============================================================================
--- trunk/libs/container/test/static_vector_test.cpp Sun Sep 29 07:38:47 2013 (r85998)
+++ trunk/libs/container/test/static_vector_test.cpp 2013-09-29 07:39:34 EDT (Sun, 29 Sep 2013) (r85999)
@@ -11,14 +11,6 @@
 #include <boost/detail/lightweight_test.hpp>
 #include <boost/detail/no_exceptions_support.hpp>
 
-// TODO: Disable parts of the unit test that should not run when BOOST_NO_EXCEPTIONS
-// if exceptions are enabled there must be a user defined throw_exception function
-#ifdef BOOST_NO_EXCEPTIONS
-namespace boost {
- void throw_exception(std::exception const &){}; // user defined
-} // namespace boost
-#endif // BOOST_NO_EXCEPTIONS
-
 #include <vector>
 #include <list>
 

Modified: trunk/libs/container/test/vector_test.hpp
==============================================================================
--- trunk/libs/container/test/vector_test.hpp Sun Sep 29 07:38:47 2013 (r85998)
+++ trunk/libs/container/test/vector_test.hpp 2013-09-29 07:39:34 EDT (Sun, 29 Sep 2013) (r85999)
@@ -78,9 +78,9 @@
    T* allocate(std::size_t n)
    {
       //Initialize memory to a pattern
- T *const p = ::new T[n];
- unsigned char *puc_raw = reinterpret_cast<unsigned char*>(p);
- std::size_t max = sizeof(T)*n;
+ const std::size_t max = sizeof(T)*n;
+ unsigned char *puc_raw = ::new unsigned char[max];
+
       if(base_t::s_ascending){
          for(std::size_t i = 0; i != max; ++i){
             puc_raw[i] = static_cast<unsigned char>(s_pattern++);
@@ -91,11 +91,11 @@
             puc_raw[i] = static_cast<unsigned char>(s_pattern--);
          }
       }
- return p;
+ return (T*)puc_raw;;
    }
 
    void deallocate(T *p, std::size_t)
- { delete[] p; }
+ { delete[] (unsigned char*)p; }
 };
 
 template<class T>


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