-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Medium
-
Code Generation Tools
-
CODEGEN-13454
-
-
-
default
-
Make y a volatile variable.
The compiler will miscompile a complicated boolean expression of a very particular form. Given a single boolean value y where y was initialized by (either explicitly or implictly) comparing some scalar value to zero, and you have a logical or expression or a logical and expression where one operand is y, and the other operand is a comparison between y and another boolean value, the compiler may generate bad code.
The keys points are:
1. x and y are boolean values (maybe "bool", but not necessarily)
2. You have a logical or (||) or logical and (&&) expression
3. y is used twice in the expression
4. The expression is of the form
a. ((x == y) || y) or
b. ((x == y) && y)
That is, if your code matches this pattern:
bool x = ??
bool y = (data != 0);
bool z = ((x == y) || y);