From: Darren Cook (darren_at_[hidden])
Date: 2005-09-21 17:53:22
>>I don't get it. If you put BOOST_ASSERT( false ) anywhere, then you
>>effectively say "never exceute this code". Otherwise there is an error
>>in the assertion itself.
> Although that's a reasonable point of view, it is not supported by the
> current documentation, according to which executing BOOST_ASSERT(false) is
> well-defined and not an error. With some configurations it will invoke
> boost::assertion_failed(), which will pop up a message box offering to
> ignore, abort or break into the debugger.
> As I said in my previous post, I find the current behaviour quite useful.
> I sometimes use assert as a convenient way of saying, "issue a warning
> message, but only in debug builds."
Same here. I'm using John Torjo's SMART_ASSERT and I have lines like:
SMART_ASSERT(false)(a)(b)(c).msg("Surely we never reach here?");
I.e. if it does reach here I can see the values of a,b and c and can
immediately see if it is a use case I never thought of, or a program bug.
But instead of adding BOOST_ASSUME() I'd prefer the use of _assume() in
BOOST_ASSERT be controlled by a define and off by default. It is a
relatively minor optimization so could just be enabled by those who need
the speed and know their code does not do ASSERT(false).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk