
## Motivation `-Wunreachable-code` missed—or in rare cases crashed on—tautological comparisons such as ```cpp x != 0 || x != 1.0 // always true x == 0 && x == 1.0 // always false ``` when the *same* variable appears on both sides but one operand goes through a floating‑rank promotion that is target‑dependent. On back‑ends with **native half‑precision** (`_Float16` / `__fp16`) such as AArch64 `+fullfp16`, no promotion occurs, so the cast stacks between the two operands differ and the existing heuristic bails out. ## Technical description * **Extends `Expr::isSameComparisonOperand()`** – the helper now ignores parentheses **and value‑preserving implicit casts** (`CK_LValueToRValue`, floating‑rank `CK_FloatingCast`) before comparing the underlying operands. This prevents floating‑rank promotions and lvalue‑to‑rvalue conversions from blocking the unreachable‑code diagnostic on targets with native FP16. *No change needed in `CheckIncorrectLogicOperator`; it simply benefits from the improved helper.* * **Regression test** – `warn-unreachable_crash.cpp` updated to cover both the promoted case (x86‑64) and the native‑half case (AArch64 `+fullfp16`). * **Docs** – release‑note bullet added under *Bug Fixes in This Version*. @ziqingluo-90 @yronglin Could you please review promptly? (feel free to also merge it on my behalf) Thanks! Fixes #149967 Co-authored-by: Zeeshan Siddiqui <mzs@ntdev.microsoft.com>
C language Family Front-end
Welcome to Clang.
This is a compiler front-end for the C family of languages (C, C++ and Objective-C) which is built as part of the LLVM compiler infrastructure project.
Unlike many other compiler frontends, Clang is useful for a number of things beyond just compiling code: we intend for Clang to be host to a number of different source-level tools. One example of this is the Clang Static Analyzer.
If you're interested in more (including how to build Clang) it is best to read the relevant websites. Here are some pointers:
-
Information on Clang: http://clang.llvm.org/
-
Building and using Clang: http://clang.llvm.org/get_started.html
-
Clang Static Analyzer: http://clang-analyzer.llvm.org/
-
Information on the LLVM project: http://llvm.org/
-
If you have questions or comments about Clang, a great place to discuss them is on the Clang forums:
-
If you find a bug in Clang, please file it in the LLVM bug tracker: