From 31d7f3875fa58ad0b23467aa63717dff8298ea24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 21 Oct 2020 22:41:12 +0200 Subject: [PATCH] Fixes #167 ("error: the address of 'msg' will always evaluate as 'true' warning with GCC 4.4"). --- include/boost/container/throw_exception.hpp | 25 +++++++++------------ 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/include/boost/container/throw_exception.hpp b/include/boost/container/throw_exception.hpp index 59eaba6..e2a0f6a 100644 --- a/include/boost/container/throw_exception.hpp +++ b/include/boost/container/throw_exception.hpp @@ -21,6 +21,7 @@ #include #include +#include #ifndef BOOST_NO_EXCEPTIONS #include //for std exception types @@ -51,41 +52,35 @@ namespace container { BOOST_NORETURN inline void throw_bad_alloc() { - const char msg[] = "boost::container bad_alloc thrown"; - (void)msg; - BOOST_ASSERT(!msg); + BOOST_ASSERT(!"boost::container bad_alloc thrown"); std::abort(); } BOOST_NORETURN inline void throw_out_of_range(const char* str) { - const char msg[] = "boost::container out_of_range thrown"; - (void)msg; (void)str; - BOOST_ASSERT_MSG(!msg, str); + boost::ignore_unused(str); + BOOST_ASSERT_MSG(!"boost::container out_of_range thrown", str); std::abort(); } BOOST_NORETURN inline void throw_length_error(const char* str) { - const char msg[] = "boost::container length_error thrown"; - (void)msg; (void)str; - BOOST_ASSERT_MSG(!msg, str); + boost::ignore_unused(str); + BOOST_ASSERT_MSG(!"boost::container length_error thrown", str); std::abort(); } BOOST_NORETURN inline void throw_logic_error(const char* str) { - const char msg[] = "boost::container logic_error thrown"; - (void)msg; (void)str; - BOOST_ASSERT_MSG(!msg, str); + boost::ignore_unused(str); + BOOST_ASSERT_MSG(!"boost::container logic_error thrown", str); std::abort(); } BOOST_NORETURN inline void throw_runtime_error(const char* str) { - const char msg[] = "boost::container runtime_error thrown"; - (void)msg; (void)str; - BOOST_ASSERT_MSG(!msg, str); + boost::ignore_unused(str); + BOOST_ASSERT_MSG(!"boost::container runtime_error thrown", str); std::abort(); }