Boost logo

Boost :

From: Dave Harris (brangdon_at_[hidden])
Date: 2005-09-21 13:01:12


In-Reply-To: <loom.20050921T155516-756_at_[hidden]>
nesotto_at_[hidden] (Thorsten Ottosen) wrote (abridged):
> 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."

I actually work with MFC and use their ASSERT macro rather than
BOOST_ASSERT. From a selfish point of view I don't care what boost does
here because it won't hurt me. My concern is that other people may have
used BOOST_ASSERT the same way I use MFC ASSERT. If you're confident
no-one has, fine - but I don't see anything in the documentation which
says my use is wrong.

The documentation does say, "The macro is intended to be used in Boost
libraries", which I suppose means we don't need to worry about breaking
end-user code.

> (The effect of removing an assertion must not be any in a correct
> program).

Having assert expand to __assume would not be the same as removing it.

-- Dave Harris, Nottingham, UK.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk