[flang-commits] [flang] [flang][preprocessor] fix use of bitwise-and for logical-and (PR #146758)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Wed Jul 2 11:55:57 PDT 2025
================
@@ -1276,14 +1276,19 @@ static std::int64_t ExpressionValue(const TokenSequence &token,
left = right >= 64 ? 0 : left >> right;
break;
case BITAND:
- case AND:
left = left & right;
break;
+ // (bool)(1 && 2) != (bool)(1 & 2), we can't use bitwise AND here.
+ case AND:
+ left = left && right;
+ break;
case BITXOR:
left = left ^ right;
break;
- case BITOR:
+ // (bool)(1 || 2) == (bool)(1 | 2), seems like we can use `|` here.
+ // But should we?
----------------
klausler wrote:
We should not. The result has to be 1 or 0.
https://github.com/llvm/llvm-project/pull/146758
More information about the flang-commits
mailing list