From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-09-06 11:36:00
On Friday 06 September 2002 11:49 am, Fernando Cacciola wrote:
> Could you elaborate specifically which uses could have tribool which cannot
> be covered with a comparison policy returning bool?
That would be me :) Static analysis is one domain where we need a full tribool
result from interval comparisons. We might have the code:
1: int x, y;
2: // x and y get their values here
3: if (x < y)
Now "execute" this program fragment symbolically, to cover _all_ executions in
one run. At line 3, we need to compute the result of the conditional 'x < y'.
Three things might happen:
1) We might know that x < y will always be true (because the interval in
which x's value lies is below the value in which y's value lies). Here, we
can just take the 'if' branch and ignore the 'else' (on-the-fly dead code
elimination, if you will).
2) We might know that x < y will always be false. Here, we ignore the 'if'
branch and just take the 'else' branch.
3) We might not be able to determine what the value of 'x < y' will be, so
we end up taking both the 'if' and 'else' branches simultaneously.
In this kind of static analysis (abstract interpretation), a 'bool' variable
in the program code will actually be represented by a tribool, because we
might not know the actual value of the boolean variable when we analyze at
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk