Bug in iterator_range when NDEBUG not defined but boost asserts are enabled

iterator_range.hpp defines is_singular() if NDEBUG is not defined but it calls is_singular through the BOOST_ASSERT macro. Unfortunately it is possible to enable BOOST_ASSERT and have NDEBUG defined which leads to a compilation error. To see this compile the iterator_range.cpp example included with the library with the following defines: gcc -DBOOST_ENABLE_ASSERT_HANDLER -I/usr/local/src/boost-trunk/ -DNDEBUG -c iterator_range.cpp John.

John Reid skrev:
iterator_range.hpp defines is_singular() if NDEBUG is not defined but it calls is_singular through the BOOST_ASSERT macro. Unfortunately it is possible to enable BOOST_ASSERT and have NDEBUG defined which leads to a compilation error.
To see this compile the iterator_range.cpp example included with the library with the following defines: gcc -DBOOST_ENABLE_ASSERT_HANDLER -I/usr/local/src/boost-trunk/ -DNDEBUG -c iterator_range.cpp
I'll look into this when I get some time. I guess most people write assertions under the implicit assumption that they are either on or off. -Thorsten

on Tue May 13 2008, Thorsten Ottosen <thorsten.ottosen-AT-dezide.com> wrote:
John Reid skrev:
iterator_range.hpp defines is_singular() if NDEBUG is not defined but it calls is_singular through the BOOST_ASSERT macro. Unfortunately it is possible to enable BOOST_ASSERT and have NDEBUG defined which leads to a compilation error.
To see this compile the iterator_range.cpp example included with the library with the following defines: gcc -DBOOST_ENABLE_ASSERT_HANDLER -I/usr/local/src/boost-trunk/ -DNDEBUG -c iterator_range.cpp
I'll look into this when I get some time. I guess most people write assertions under the implicit assumption that they are either on or off.
I dunno. IIUC part of the motivation for BOOST_ASSERT was to have something that would be tested even when NDEBUG was defined. -- Dave Abrahams BoostPro Computing http://www.boostpro.com

On Tue, May 13, 2008 at 3:00 PM, David Abrahams <dave@boostpro.com> wrote:
on Tue May 13 2008, Thorsten Ottosen <thorsten.ottosen-AT-dezide.com> wrote:
John Reid skrev:
iterator_range.hpp defines is_singular() if NDEBUG is not defined but it calls is_singular through the BOOST_ASSERT macro. Unfortunately it is possible to enable BOOST_ASSERT and have NDEBUG defined which leads to a compilation error.
To see this compile the iterator_range.cpp example included with the library with the following defines: gcc -DBOOST_ENABLE_ASSERT_HANDLER -I/usr/local/src/boost-trunk/ -DNDEBUG -c iterator_range.cpp
I'll look into this when I get some time. I guess most people write assertions under the implicit assumption that they are either on or off.
Are there any news? There are 2 ticket which deal with this (and could be closed): http://svn.boost.org/trac/boost/ticket/1694 http://svn.boost.org/trac/boost/ticket/1793 Attached is a patch which solves the issue by using #ifndef BOOST_DISABLE_ASSERTS instead of NDEBUG HTH, Stephan p.s.: the trac spam checker doesn't let me attach the patch to the ticket...
participants (4)
-
David Abrahams
-
John Reid
-
Stephan Diederich
-
Thorsten Ottosen