Boost logo

Boost :

From: Dave Harris (brangdon_at_[hidden])
Date: 2005-09-24 05:26:35

In-Reply-To: <200509211851.j8LIp8VY019052_at_[hidden]>
stewart_at_[hidden] (Rob Stewart) wrote (abridged):
> That misses what BOOST_ASSUME should do when
> BOOST_DISABLE_ASSERTS is not defined. With BOOST_ASSERT enabled,
> BOOST_ASSUME should call both BOOST_ASSERT and __assume():


Consider the sequence:

         BOOST_ASSERT(e); __assume(e)

Suppose (e) is true. Then BOOST_ASSERT does nothing, so why invoke it? If
(e) is false, then the __assume tells us the sequence won't be executed at
all, and both it and the BOOST_ASSERT can be optimised away. Whatever it
is you want BOOST_ASSERT to do, you can't rely on it happening. It will
depend on how clever the optimiser is, which will vary from platform to

In addition, it evaluates (e) twice. That's bad practice for a macro. It
would be acceptable if it were necessary (and we certainly hope (e) has no
side effects and that its value doesn't change between the assert and the
assume) but here there is no need for it.

-- Dave Harris, Nottingham, UK.

Boost list run by bdawes at, gregod at, cpdaniel at, john at