Please use BOOST_ASSERT_MSG(x, "message") instead of BOOST_ASSERT(x && "message")

Several libraries, including Boost.Array, use things like BOOST_ASSERT( i < N && "out of range" ); This causes warnings with EDG-based compilers. It would be nice if library authors could replace this with something like BOOST_ASSERT_MSG( i < N, "out of range" ); Not only will it make those warnings disappear, it will also enable users to use those messages more efficiently in custom assert handlers. Thank you.

Mathias Gaunard <mathias.gaunard@ens-lyon.org> writes:
Several libraries, including Boost.Array, use things like BOOST_ASSERT( i < N && "out of range" );
This causes warnings with EDG-based compilers.
It would be nice if library authors could replace this with something like BOOST_ASSERT_MSG( i < N, "out of range" );
Not only will it make those warnings disappear, it will also enable users to use those messages more efficiently in custom assert handlers.
Thank you.
Wont this silently skip the assert message in compilers that don't support C++11 static_assert and make the error less clear in return? Philipp Moeller

On Feb 24, 2012, at 5:46 AM, Mathias Gaunard wrote:
Several libraries, including Boost.Array, use things like BOOST_ASSERT( i < N && "out of range" );
This causes warnings with EDG-based compilers.
It would be nice if library authors could replace this with something like BOOST_ASSERT_MSG( i < N, "out of range" );
Not only will it make those warnings disappear, it will also enable users to use those messages more efficiently in custom assert handlers.
Boost.Array updated in r77135. -- Marshall Marshall Clow Idio Software <mailto:mclow.lists@gmail.com> A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait). -- Yu Suzuki
participants (3)
-
Marshall Clow
-
Mathias Gaunard
-
Philipp Moeller