<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/60256>60256</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang should warn about chained comparisons like `a > b > c`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:diagnostics
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          zmodem
      </td>
    </tr>
</table>

<pre>
    We had this `=` vs. `==` bug in Chromium recently:

```
int f(int);
int g(int a) {
  a == f(a) > 1 ? 1 : f(a);
  // stuff
}
```

In most cases, Clang would catch a `=` vs `==` bug with `-Wunused-comparison`, but in this case the unintentional comparison became an operand to the ternary operator, and no warning fired.

Perhaps there should be warning for the general case of "chained comparisons" that would catch the above as well as code like:

```
void h(int a, int b, int c) {
  if (a > b > c) {
 // stuff...
  }
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8U02P6yoM_TVkYzUi5KPtIouZ9lV6u7ebtROcwLsEKiCt5v76K5JO2_nQlSIHbGzscw4Ygh4tUcvqV1YfM5yjcr79PTlJU9Y5-d6-ESiUEJUOwBrOyiNrOFxC_rFbHd08grZwUN5Nep7AU082mndWvjB-ZPzDNvz2LVttIwxM7LSNTOxZ-fpwj6sbkIk9sO0tAoCwXrrkrcHyHyiAlafFvtwD93IATJyYOEGI8zDcGtkef-xotf9amFyI0GOgwMQBDgbtCFc3Gwk9xl6lPp7Q-A7GVUeVvJu32c6B5KZ30xm9Ds6ms-IA3RwTZAuy6SKIimC22kayUTuLBh450FGPEwFacGfyaCVEt2RE8hb9--qOzqfSKWwdXNFbbUcYtCeZPw_4H3mF55AKeIKglsE6emQ4vxQfyZJPjaT-3ABMiF6htiSfegtMCIgK4yeAUjp27kKAAa5kTPr3ThIY_Yv-rouL0xLUQwEHSIvuY9F_0YROje1wUUK32C8nnvnP8_wui7sIvqkhk20p9-UeM2qLZlvVTdUUTabaphu2ku87XgxYF0WFnJc1CRwKWe3KmjLdCi5KXoiqEDUvmlxwrId9uSuaoa92BbKK04Ta5MZcptz5MdMhzNQ2XNRNZrAjE5YHKUSfZMfKF6lxtC5E3Ses00v1bcredPMYWMWNDjE86kUdDbWrZm_cJmITHXOEHwhcKElq_Yxhw7PZm1bFeA6JsAXFUUc1d3nvJiZO6crbb3P27n_qIxOnZZ7AxGkZ6U8AAAD__2zaTSM">