From 59c5ed7781e192306cee37e009226771a479965d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 29 Sep 2013 11:39:34 +0000 Subject: [PATCH] Fixed error in default_init_allocator, it should not construct objects, only allocate raw memory. [SVN r85999] --- test/static_vector_test.cpp | 8 -------- test/vector_test.hpp | 10 +++++----- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/test/static_vector_test.cpp b/test/static_vector_test.cpp index 30914af..4521aef 100644 --- a/test/static_vector_test.cpp +++ b/test/static_vector_test.cpp @@ -11,14 +11,6 @@ #include #include -// 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 #include diff --git a/test/vector_test.hpp b/test/vector_test.hpp index 3dc2401..0eb229b 100644 --- a/test/vector_test.hpp +++ b/test/vector_test.hpp @@ -78,9 +78,9 @@ class default_init_allocator T* allocate(std::size_t n) { //Initialize memory to a pattern - T *const p = ::new T[n]; - unsigned char *puc_raw = reinterpret_cast(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(s_pattern++); @@ -91,11 +91,11 @@ class default_init_allocator puc_raw[i] = static_cast(s_pattern--); } } - return p; + return (T*)puc_raw;; } void deallocate(T *p, std::size_t) - { delete[] p; } + { delete[] (unsigned char*)p; } }; template