From 71317671eccb460ab33dee42f75c776310f7c3bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 9 Dec 2017 13:01:02 +0100 Subject: [PATCH] Add GCC's "-Wuninitialized" workaround. When initializing the pointer of flags part of an uninitialized pointer plus bit object, the other part is used uninitialized. It's harmless warning but annoying for the user. --- doc/intrusive.qbk | 7 +++++++ include/boost/intrusive/pointer_plus_bits.hpp | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/doc/intrusive.qbk b/doc/intrusive.qbk index fbd6a93..cb76699 100644 --- a/doc/intrusive.qbk +++ b/doc/intrusive.qbk @@ -3870,6 +3870,13 @@ to be inserted in intrusive containers are allocated using `std::vector` or `std [section:release_notes Release Notes] +[section:release_notes_boost_1_67_00 Boost 1.67 Release] + +* Fixed bugs: + * [@https://github.com/boostorg/intrusive/issues/29 GitHub Issues #29: ['Uninitialized variable warning pointer_plus_bits.hpp]] + +[endsect] + [section:release_notes_boost_1_65_00 Boost 1.65 Release] * Fixed bugs: diff --git a/include/boost/intrusive/pointer_plus_bits.hpp b/include/boost/intrusive/pointer_plus_bits.hpp index dfde66b..a39da32 100644 --- a/include/boost/intrusive/pointer_plus_bits.hpp +++ b/include/boost/intrusive/pointer_plus_bits.hpp @@ -22,6 +22,17 @@ # pragma once #endif + +//GCC reports uninitialized values when an uninitialized pointer plus bits type +//is asigned some bits or some pointer value, but that's ok, because we don't want +//to default initialize parts that are not being updated. +#if defined(BOOST_GCC) +# if (BOOST_GCC >= 40600) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wuninitialized" +# endif +#endif + namespace boost { namespace intrusive { @@ -89,6 +100,10 @@ struct pointer_plus_bits } //namespace intrusive } //namespace boost +#if defined(BOOST_GCC) && (BOOST_GCC >= 40600) +# pragma GCC diagnostic pop +#endif + #include #endif //BOOST_INTRUSIVE_POINTER_PLUS_BITS_HPP