CIL mistakenly casts the operands of && and || to intType, when in fact they are only required to have scalar type. This can lead to a bug if the operands have type larger than int and have values which truncate to 0 when cast to an int (and if useLogicalOperators is set to true). I believe removing the cast solves the problem, but I'm not sure whether enumerations should still be cast to intType.
Patch: --- cabs2cil.ml 2009-08-13 15:45:33.862143354 -0400 +++ orig_cabs2cil.ml 2009-08-06 16:58:57.878935879 -0400 @@ -4632,7 +4579,9 @@ CEAnd (ce1, ce2) | CEExp(se1, e1'), CEExp (se2, e2') when !useLogicalOperators && isEmpty se1 && isEmpty se2 -> - CEExp (empty, BinOp(LAnd, e1', e2', intType)) + CEExp (empty, BinOp(LAnd, + makeCast e1' intType, + makeCast e2' intType, intType)) | _ -> CEAnd (ce1, ce2) end @@ -4652,7 +4601,8 @@ | CEExp (se1, e1'), CEExp (se2, e2') when !useLogicalOperators && isEmpty se1 && isEmpty se2 -> - CEExp (empty, BinOp(LOr, e1', e2', intType)) + CEExp (empty, BinOp(LOr, makeCast e1' intType, + makeCast e2' intType, intType)) | _ -> CEOr (ce1, ce2) end Program which exhibits the bug when run with useLogicalOperators is set to true: #include <stdio.h> int main() { long long x = 0x100000000LL; if (x && x) printf("x\n"); return 0; } ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ CIL-users mailing list CIL-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cil-users