Skip to content

Commit f696a67

Browse files
committed
Use Boolean operators compute xor, or, and over bool
Using bitwise xor (^) is an operation over integers, and triggers a warning by Visual Studio. The same is true for |, &; the latter were only sometimes used for this purpose, which also makes this a consistency-fix.
1 parent 8d3c9aa commit f696a67

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/util/mp_arith.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ mp_integer bitwise_xor(const mp_integer &a, const mp_integer &b)
269269
if(a.is_ulong() && b.is_ulong())
270270
return a.to_ulong() ^ b.to_ulong();
271271

272-
return bitwise(a, b, [](bool a, bool b) { return a ^ b; });
272+
return bitwise(a, b, [](bool a, bool b) { return a != b; });
273273
}
274274

275275
/// arithmetic left shift bitwise operations only make sense on native objects,

src/util/simplify_expr_int.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -734,11 +734,11 @@ bool simplify_exprt::simplify_bitwise(exprt &expr)
734734
std::function<bool(bool, bool)> f;
735735

736736
if(expr.id()==ID_bitand)
737-
f = [](bool a, bool b) { return a & b; };
737+
f = [](bool a, bool b) { return a && b; };
738738
else if(expr.id()==ID_bitor)
739-
f = [](bool a, bool b) { return a | b; };
739+
f = [](bool a, bool b) { return a || b; };
740740
else if(expr.id()==ID_bitxor)
741-
f = [](bool a, bool b) { return a ^ b; };
741+
f = [](bool a, bool b) { return a != b; };
742742
else
743743
UNREACHABLE;
744744

0 commit comments

Comments
 (0)