[clang] [clang][CFG] Fix assertion failure in checkIncorrectLogicOperator (PR #142897)
Ziqing Luo via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 5 18:19:11 PDT 2025
================
@@ -1261,6 +1261,28 @@ class CFGBuilder {
L2Result.Val.getKind() == APValue::Float) {
llvm::APFloat L1 = L1Result.Val.getFloat();
llvm::APFloat L2 = L2Result.Val.getFloat();
+ // Note that L1 and L2 do not necessarily have the same type. For example
+ // `x != 0 || x != 1.0`, if `x` is a float16, the two literals `0` and
+ // `1.0` are float16 and double respectively. In this case, we should do
+ // a conversion before comparing L1 and L2. Their types must be
+ // compatible since they are comparing with the same DRE.
+ int8_t Order = Context->getFloatingTypeOrder(NumExpr1->getType(),
----------------
ziqingluo-90 wrote:
good point, I initially thought it just returns -1,0, or 1 but it's not the case.
https://github.com/llvm/llvm-project/pull/142897
More information about the cfe-commits
mailing list