From a32ccd82f3f2f4d61246eae39a8bac70e986ebd8 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Mon, 22 Oct 2018 19:00:16 +0900 Subject: [PATCH] fix UB in test_value (use after move) --- tests/test_value.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/test_value.cpp b/tests/test_value.cpp index 345da6eb..1e24088d 100644 --- a/tests/test_value.cpp +++ b/tests/test_value.cpp @@ -178,6 +178,14 @@ BOOST_AUTO_TEST_CASE(test_value_copy_move_substitution) BOOST_CHECK_EQUAL(v2.cast(), f); BOOST_CHECK_EQUAL(v3.cast(), s); + const auto f_ = f; + const auto s_ = s; + const auto d_ = d; + const auto a_ = a; + const auto t_ = t; + const auto b_ = b; + const auto i_ = i; + v1 = std::move(f); v2 = std::move(s); v3 = std::move(d); @@ -194,10 +202,10 @@ BOOST_AUTO_TEST_CASE(test_value_copy_move_substitution) BOOST_CHECK_EQUAL(v6.type(), toml::value_t::Boolean); BOOST_CHECK_EQUAL(v7.type(), toml::value_t::Integer); - BOOST_CHECK_EQUAL(v6.cast(), b); - BOOST_CHECK_EQUAL(v7.cast(), i); - BOOST_CHECK_EQUAL(v1.cast(), f); - BOOST_CHECK_EQUAL(v2.cast(), s); + BOOST_CHECK_EQUAL(v6.cast(), b_); + BOOST_CHECK_EQUAL(v7.cast(), i_); + BOOST_CHECK_EQUAL(v1.cast(), f_); + BOOST_CHECK_EQUAL(v2.cast(), s_); } BOOST_AUTO_TEST_CASE(test_value_initializer_list)