Issue |
149967
|
Summary |
Incorrect tautology diagnostic with native half‑precision
|
Labels |
new issue
|
Assignees |
|
Reporter |
codemzs
|
`-Wunreachable-code` is silent on targets with native FP16 support
----------------------------------------------------------------------------
### Problem
The tautology/contradiction check in **`CheckIncorrectLogicOperator`** fails on targets with **native scalar FP16** (e.g., AArch64 `+fullfp16`).
It still works on x86‑64, so the lapse went unnoticed.
| Triple | FP16 handling | Warning? |
| ------ | ------------- | -------- |
| `x86_64-unknown-linux-gnu` | `__fp16` / `_Float16` are *promoted* to `float` (extra cast) | ✔️ emitted |
| `aarch64-unknown-linux-gnu +fullfp16` | no promotion (native arithmetic) | ❌ **missing** |
---
### Why promotion hides the bug
#### x86‑64 AST — *warning appears*
```text
BinaryOperator '_Bool' '!='
├─ ImplicitCastExpr 'float' <FloatingCast>
│ └─ ImplicitCastExpr '__fp16' <LValueToRValue>
│ └─ DeclRefExpr '__fp16' ParmVar 'x'
└─ ImplicitCastExpr 'float' <IntegralToFloating>
└─ IntegerLiteral 'int' 0
```
AArch64 +fullfp16 AST — warning lost
```text
BinaryOperator '_Bool' '!='
├─ ImplicitCastExpr '__fp16' <LValueToRValue>
│ └─ DeclRefExpr '__fp16' ParmVar 'x'
└─ ImplicitCastExpr '__fp16' <IntegralToFloating>
└─ IntegerLiteral 'int' 0
```
No FloatingCast → operands’ cast chains differ →`Expr::isSameComparisonOperand()` returns false → diagnostic short‑circuits.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs