From 4301005b255caa3af12c6c368f8a422c5105e767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 29 Dec 2021 23:43:44 +0100 Subject: [PATCH] Remove some Wmaybe-uninitialized warnings for GCC 11 --- .../container/detail/advanced_insert_int.hpp | 16 +++++----- include/boost/container/detail/flat_tree.hpp | 32 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/boost/container/detail/advanced_insert_int.hpp b/include/boost/container/detail/advanced_insert_int.hpp index fef1303..18c7935 100644 --- a/include/boost/container/detail/advanced_insert_int.hpp +++ b/include/boost/container/detail/advanced_insert_int.hpp @@ -131,8 +131,8 @@ struct insert_value_initialized_n_proxy while (n){ --n; storage_t v; - value_type *vp = move_detail::force_ptr(static_cast(v.data)); - alloc_traits::construct(a, vp); + alloc_traits::construct(a, move_detail::force_ptr(&v)); + value_type *vp = move_detail::force_ptr(&v); value_destructor on_exit(a, *vp); (void)on_exit; *p = ::boost::move(*vp); ++p; @@ -156,8 +156,8 @@ struct insert_default_initialized_n_proxy while (n){ --n; typename dtl::aligned_storage::value>::type v; - value_type *vp = move_detail::force_ptr(v.data); - alloc_traits::construct(a, vp, default_init); + alloc_traits::construct(a, move_detail::force_ptr(&v), default_init); + value_type *vp = move_detail::force_ptr(&v); value_destructor on_exit(a, *vp); (void)on_exit; *p = ::boost::move(*vp); ++p; @@ -297,8 +297,8 @@ struct insert_emplace_proxy { BOOST_ASSERT(n ==1); (void)n; typename dtl::aligned_storage::value>::type v; - value_type *vp = move_detail::force_ptr(v.data); - alloc_traits::construct(a, vp, ::boost::forward(get(this->args_))...); + alloc_traits::construct(a, move_detail::force_ptr(&v), ::boost::forward(get(this->args_))...); + value_type *vp = move_detail::force_ptr(&v); BOOST_TRY{ *p = ::boost::move(*vp); } @@ -417,8 +417,8 @@ struct insert_emplace_proxy_arg##N\ {\ BOOST_ASSERT(n == 1); (void)n;\ typename dtl::aligned_storage::value>::type v;\ - value_type *vp = move_detail::force_ptr(v.data);\ - alloc_traits::construct(a, vp BOOST_MOVE_I##N BOOST_MOVE_MFWD##N);\ + alloc_traits::construct(a, move_detail::force_ptr(&v) BOOST_MOVE_I##N BOOST_MOVE_MFWD##N);\ + value_type *vp = move_detail::force_ptr(&v);\ BOOST_TRY{\ *p = ::boost::move(*vp);\ }\ diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp index 4fa729a..50d0768 100644 --- a/include/boost/container/detail/flat_tree.hpp +++ b/include/boost/container/detail/flat_tree.hpp @@ -961,9 +961,9 @@ class flat_tree std::pair emplace_unique(BOOST_FWD_REF(Args)... args) { typename dtl::aligned_storage::value>::type v; - value_type *pval = move_detail::force_ptr(v.data); get_stored_allocator_noconst_return_t a = this->get_stored_allocator(); - stored_allocator_traits::construct(a, pval, ::boost::forward(args)... ); + stored_allocator_traits::construct(a, move_detail::force_ptr(&v), ::boost::forward(args)... ); + value_type *pval = move_detail::force_ptr(&v); value_destructor d(a, *pval); return this->insert_unique(::boost::move(*pval)); } @@ -973,9 +973,9 @@ class flat_tree { //hint checked in insert_unique typename dtl::aligned_storage::value>::type v; - value_type *pval = move_detail::force_ptr(v.data); get_stored_allocator_noconst_return_t a = this->get_stored_allocator(); - stored_allocator_traits::construct(a, pval, ::boost::forward(args)... ); + stored_allocator_traits::construct(a, move_detail::force_ptr(&v), ::boost::forward(args)... ); + value_type *pval = move_detail::force_ptr(&v); value_destructor d(a, *pval); return this->insert_unique(hint, ::boost::move(*pval)); } @@ -984,9 +984,9 @@ class flat_tree iterator emplace_equal(BOOST_FWD_REF(Args)... args) { typename dtl::aligned_storage::value>::type v; - value_type *pval = move_detail::force_ptr(v.data); get_stored_allocator_noconst_return_t a = this->get_stored_allocator(); - stored_allocator_traits::construct(a, pval, ::boost::forward(args)... ); + stored_allocator_traits::construct(a, move_detail::force_ptr(&v), ::boost::forward(args)... ); + value_type *pval = move_detail::force_ptr(&v); value_destructor d(a, *pval); return this->insert_equal(::boost::move(*pval)); } @@ -996,9 +996,9 @@ class flat_tree { //hint checked in insert_equal typename dtl::aligned_storage::value>::type v; - value_type *pval = move_detail::force_ptr(v.data); get_stored_allocator_noconst_return_t a = this->get_stored_allocator(); - stored_allocator_traits::construct(a, pval, ::boost::forward(args)... ); + stored_allocator_traits::construct(a, move_detail::force_ptr(&v), ::boost::forward(args)... ); + value_type *pval = move_detail::force_ptr(&v); value_destructor d(a, *pval); return this->insert_equal(hint, ::boost::move(*pval)); } @@ -1030,9 +1030,9 @@ class flat_tree std::pair emplace_unique(BOOST_MOVE_UREF##N)\ {\ typename dtl::aligned_storage::value>::type v;\ - value_type *pval = move_detail::force_ptr(v.data);\ get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\ - stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + stored_allocator_traits::construct(a, move_detail::force_ptr(&v) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + value_type *pval = move_detail::force_ptr(&v);\ value_destructor d(a, *pval);\ return this->insert_unique(::boost::move(*pval));\ }\ @@ -1041,9 +1041,9 @@ class flat_tree iterator emplace_hint_unique(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ {\ typename dtl::aligned_storage::value>::type v;\ - value_type *pval = move_detail::force_ptr(v.data);\ get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\ - stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + stored_allocator_traits::construct(a, move_detail::force_ptr(&v) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + value_type *pval = move_detail::force_ptr(&v);\ value_destructor d(a, *pval);\ return this->insert_unique(hint, ::boost::move(*pval));\ }\ @@ -1052,9 +1052,9 @@ class flat_tree iterator emplace_equal(BOOST_MOVE_UREF##N)\ {\ typename dtl::aligned_storage::value>::type v;\ - value_type *pval = move_detail::force_ptr(v.data);\ get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\ - stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + stored_allocator_traits::construct(a, move_detail::force_ptr(&v) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + value_type *pval = move_detail::force_ptr(&v);\ value_destructor d(a, *pval);\ return this->insert_equal(::boost::move(*pval));\ }\ @@ -1063,9 +1063,9 @@ class flat_tree iterator emplace_hint_equal(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ {\ typename dtl::aligned_storage ::value>::type v;\ - value_type *pval = move_detail::force_ptr(v.data);\ get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\ - stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + stored_allocator_traits::construct(a, move_detail::force_ptr(&v) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + value_type *pval = move_detail::force_ptr(&v);\ value_destructor d(a, *pval);\ return this->insert_equal(hint, ::boost::move(*pval));\ }\