From 599c58825b34bd7274e1b16c7260502949229bce Mon Sep 17 00:00:00 2001 From: Robert Ramey Date: Sun, 27 Oct 2013 20:50:26 +0000 Subject: [PATCH] correct rounding fix memory leak for constructor failure in load_construct_data fix another bug in loading pointers [SVN r86487] --- example/demo_dll_a.hpp | 8 ++++---- src/basic_iarchive.cpp | 12 +++++++----- test/A.cpp | 8 ++++---- test/test_codecvt_null.cpp | 2 +- test/test_complex.cpp | 4 ++-- test/test_iterators.cpp | 2 +- test/test_map.cpp | 2 +- test/test_set.cpp | 2 +- test/test_simple_class.cpp | 8 ++++---- test/test_utf8_codecvt.cpp | 2 +- 10 files changed, 26 insertions(+), 24 deletions(-) diff --git a/example/demo_dll_a.hpp b/example/demo_dll_a.hpp index 827a9bbd..08e7bd8e 100644 --- a/example/demo_dll_a.hpp +++ b/example/demo_dll_a.hpp @@ -245,13 +245,13 @@ inline bool A::operator==(const A &rhs) const return false; if(v != rhs.v) return false; - if(w == 0 && std::fabs(rhs.w) > std::numeric_limits::epsilon()) + if(w == 0 && std::fabs(rhs.w) > 2 * std::numeric_limits::round_error()) return false; - if(std::fabs(rhs.w/w - 1.0) > std::numeric_limits::epsilon()) + if(std::fabs(rhs.w/w - 1.0) > 2 * std::numeric_limits::round_error()) return false; - if(x == 0 && std::fabs(rhs.x - x) > std::numeric_limits::epsilon()) + if(x == 0 && std::fabs(rhs.x - x) > 2 * std::numeric_limits::round_error()) return false; - if(std::fabs(rhs.x/x - 1.0) > std::numeric_limits::epsilon()) + if(std::fabs(rhs.x/x - 1.0) > 2 * std::numeric_limits::round_error()) return false; if(0 != y.compare(rhs.y)) return false; diff --git a/src/basic_iarchive.cpp b/src/basic_iarchive.cpp index 796cd798..442b0b8c 100644 --- a/src/basic_iarchive.cpp +++ b/src/basic_iarchive.cpp @@ -495,14 +495,16 @@ basic_iarchive_impl::load_pointer( // cyclic strucures object_id_vector.push_back(aobject(t, cid)); + // remember that that the address of these elements could change + // when we make another call so don't use the address bpis_ptr->load_object_ptr( - ar, - object_id_vector[ui].address, - co.file_version + ar, + t, + m_pending.version ); - t = object_id_vector[ui].address; - object_id_vector[ui].loaded_as_pointer = true; BOOST_ASSERT(NULL != t); + object_id_vector[ui].address = t; + object_id_vector[ui].loaded_as_pointer = true; } return bpis_ptr; diff --git a/test/A.cpp b/test/A.cpp index bd3e9fb9..57a19341 100644 --- a/test/A.cpp +++ b/test/A.cpp @@ -148,13 +148,13 @@ bool A::operator==(const A &rhs) const return false; if(v != rhs.v) return false; - if(w == 0 && std::fabs(rhs.w) > std::numeric_limits::epsilon()) + if(w == 0 && std::fabs(rhs.w) > 2 * std::numeric_limits::round_error()) return false; - if(std::fabs(rhs.w/w - 1.0) > std::numeric_limits::epsilon()) + if(std::fabs(rhs.w/w - 1.0) > 2 * std::numeric_limits::round_error()) return false; - if(x == 0 && std::fabs(rhs.x - x) > std::numeric_limits::epsilon()) + if(x == 0 && std::fabs(rhs.x - x) > 2 * std::numeric_limits::round_error()) return false; - if(std::fabs(rhs.x/x - 1.0) > std::numeric_limits::epsilon()) + if(std::fabs(rhs.x/x - 1.0) > 2 * std::numeric_limits::round_error()) return false; if(0 != y.compare(rhs.y)) return false; diff --git a/test/test_codecvt_null.cpp b/test/test_codecvt_null.cpp index d8ecdf8a..40abd888 100644 --- a/test/test_codecvt_null.cpp +++ b/test/test_codecvt_null.cpp @@ -10,7 +10,7 @@ // which use wchar_t as 2 byte objects will emit warnings. These should be // ignored. -#include +#include // std::copy #include #include #include diff --git a/test/test_complex.cpp b/test/test_complex.cpp index b6ee3d76..f2a2222b 100644 --- a/test/test_complex.cpp +++ b/test/test_complex.cpp @@ -68,8 +68,8 @@ int test_main( int /* argc */, char* /* argv */[] ) ia >> boost::serialization::make_nvp("adoublecomplex", b1); } - BOOST_CHECK(std::abs(a-a1) <= 2.*std::numeric_limits::round_error()); - BOOST_CHECK(std::abs(b-b1) <= 2.*std::numeric_limits::round_error()); + BOOST_CHECK(std::abs(a-a1) <= (2 * std::numeric_limits::round_error())); + BOOST_CHECK(std::abs(b-b1) <= (2 * std::numeric_limits::round_error())); std::remove(testfile); return EXIT_SUCCESS; diff --git a/test/test_iterators.cpp b/test/test_iterators.cpp index 813f8d5e..ef0ac424 100644 --- a/test/test_iterators.cpp +++ b/test/test_iterators.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include // std::copy #include #include // for rand #include diff --git a/test/test_map.cpp b/test/test_map.cpp index 7ae44269..344c28b8 100644 --- a/test/test_map.cpp +++ b/test/test_map.cpp @@ -8,7 +8,7 @@ // should pass compilation and execution -#include +#include // std::copy #include #include #include // size_t, NULL diff --git a/test/test_set.cpp b/test/test_set.cpp index 370d9389..e8322109 100644 --- a/test/test_set.cpp +++ b/test/test_set.cpp @@ -12,7 +12,7 @@ #include // remove #include -#include +#include // std::copy #include #include diff --git a/test/test_simple_class.cpp b/test/test_simple_class.cpp index d6e5693f..963dc20d 100644 --- a/test/test_simple_class.cpp +++ b/test/test_simple_class.cpp @@ -52,16 +52,16 @@ bool A::check_equal(const A &rhs) const BOOST_CHECK_EQUAL(l, rhs.l); BOOST_CHECK(!( w == 0 - && std::fabs(rhs.w) > std::numeric_limits::epsilon() + && std::fabs(rhs.w) > std::numeric_limits::round_error() )); BOOST_CHECK(!( - std::fabs(rhs.w/w - 1.0) > std::numeric_limits::epsilon() + std::fabs(rhs.w/w - 1.0) > 2.0 * std::numeric_limits::round_error() )); BOOST_CHECK(!( - x == 0 && std::fabs(rhs.x - x) > std::numeric_limits::epsilon() + x == 0 && std::fabs(rhs.x - x) > 2.0 * std::numeric_limits::round_error() )); BOOST_CHECK(!( - std::fabs(rhs.x/x - 1.0) > std::numeric_limits::epsilon() + std::fabs(rhs.x/x - 1.0) > 2.0 * std::numeric_limits::round_error() )); BOOST_CHECK(!(0 != y.compare(rhs.y))); #ifndef BOOST_NO_STD_WSTRING diff --git a/test/test_utf8_codecvt.cpp b/test/test_utf8_codecvt.cpp index a5a30a5b..f574d9b7 100644 --- a/test/test_utf8_codecvt.cpp +++ b/test/test_utf8_codecvt.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include // std::copy #include #include #include