Boost logo

Boost Users :

From: Miles Bader (miles.bader_at_[hidden])
Date: 2007-09-20 05:27:31


Thorsten Ottosen <thorsten.ottosen_at_[hidden]> writes:
> See
>
> http://www.boost.org/libs/ptr_container/doc/reference.html#disabling-the-use-of-exceptions

Ok, I just checked the preprocessed output, and exceptions are _not_
"disabled", but the boost code seems to contains tons of assertions
regardless of what mode (exceptions or no_exceptions) is used.

>> Hmmm I didn't explicitly define any macros, but what the compiled code
>> contains seems to be asserts.
>
> Ok, you need to turn assertions off in release mode, perhaps by using
> -DNDEBUG=1

Well... generally the whole concept of a special no-checking-at-all
"release mode" is a bit alien here.

I looked at the code and it seems like the basic problem is that the
boost::ptr_sequence_adapter class (at least) is somewhat
over-enthusiastic in it's use of assertions:

    template<...>
    class ptr_sequence_adapter : public
        ptr_container_detail::reversible_ptr_container< ptr_container_detail::sequence_config<T,VoidPtrSeq>,
                                            CloneAllocator >
    {
        ...

        const_reference operator[]( size_type n ) const
        {
            ((n < this->size()) ? static_cast<void> (0) : __assert_fail ("n < this->size()", "/usr/include/boost/ptr_container/ptr_sequence_adapter.hpp", 271, __PRETTY_FUNCTION__));
            ((!this->is_null( n )) ? static_cast<void> (0) : __assert_fail ("!this->is_null( n )", "/usr/include/boost/ptr_container/ptr_sequence_adapter.hpp", 272, __PRETTY_FUNCTION__));
            return *static_cast<value_type>( this->c_private()[n] );
        }
    }

Especially in this case, where there are explicitly two different
operations ("at" and operator[]) that allow the user to select which
level of low-level safety-checking he wants, such assertions seem out of
place.

-Miles

-- 
97% of everything is grunge

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net