From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2005-10-03 15:43:10


On 10/3/05, Rob Stewart <stewart_at_[hidden]> wrote:
>
> (Note that __assume(false) is useless, for it is an expression
> that the optimizer cannot use to optimize anything. So, while I
> understand that you were trying to simplify things for the
> discussion, let's also not lose sight of what is really meant
> when writing __assume(false) in the above examples.)
>

I think you're wrong.
__assume(false) means that this code will never be executed, and as
such isnt useless for the optimizer.

if(x)
{
  // do something here
}
else
{
  __assume(false);
  BOOST_LOG(dbg) << "Error! this code should never execute!" << std::endl;
}

tells the optimizer that the else will never be taken and that the
compiler can elide this and do not write the LOG code.
When you write
__assume(x != 0) it means to the optimizer that he can assume that x
will always be different from 0. When you write __assume(false) it
means that that place can never be reached.

--
   Felipe Magno de Almeida
Developer from synergy and Computer Science student from State
University of Campinas(UNICAMP).
Unicamp: http://www.ic.unicamp.br
Synergy: http://www.synergy.com.br
"There is no dark side of the moon really. Matter of fact it's all dark."