<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/76817>76817</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] `readability-implicit-bool-conversion` incorrectly treats bool bitfield comparison with bool variable
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Kaltxi
</td>
</tr>
</table>
<pre>
**Observed behaviour:**
The following code emits a warning and suggests a static cast of variable `true_value` to `int` even though the bit compared with has type `bool` and not `int` (C++20 is used).
```cpp
struct BoolField {
bool is_bool : 1; // bool type
};
BoolField field{true};
auto true_value = true; // also bool type
if (field.is_bool == true_value) { std::cout << "true"; } // Implicit conversion bool -> `int` (fix available)
```
**Temporary solution:**
Disable warning for offending line:
```cpp
if (field.is_bool == true_value) { std::cout << "true"; } // NOLINT
```
**Expected behaviour:**
No warning emitted for bool bits compared with bool variables.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VE2PozgQ_TXmUkpkDITOgUPSTKTRrnoufR8Z20CtHIzsgu78-5WdZDrd-3VaCYFcdtVzvfcKGQIOkzENq46sajO50Oh885u09I5Z5_SlYeLAxOFHF4xfjYbOjHJFt3hWHK5bjLeMH15HA72z1r3hNIBy2oA5IwWQ8Cb9FINy0hCWYTAhhQNJQgVKBgLXwyo9ys4aYDtOfjE_V2kXw3YcyMUYThQXZjUT0OiWYQQaDXRIoNx5lt5oeEMaYZQB6DKnQp1zNmZF6MnRQx0mnp6ZODJxFBwwwBKMZmK_vXZze-_49VHzfI0ABPKLIjg6Z09orAZWH-97ABEPMPxMX1YcIGfFEZg4MXG6bsab3c-zumXF8RERHgr38c3qYyTj8SSAXMjBB0fAijYtH7CkDe6vgNjHvlPh7cct23v-jXKxj01BIB01Lg7KLQSseGbFMzAhEpIQCaxu74Dfz7NFlcSYVuMDuumKv2HFt8-89_gOcpVoo9xM7L-Q_UmB5LBXc56dl_4CwdmF0E1fzNdiSNa5O613Hlzfm0nHlcXJxIR_0vR_ZOXlx-_fX17_s8Fv77NR9C_T9eJ-9RanKh6NPaardnHKPo9Ait8HKmwz3RR6X-xlZpq85qXYc1GV2diU1RPnqiyMzqvacNVJWeX9U632et_pXmTYCC5KnvMiL6q6KLflLudSdZ2ud4LvcsVKbs4S7dba9bx1fsgwhMU09e4przMrO2ND-rkIoaychg2hvkSeqjbzTUzadMsQWMktBgofZQjJpt_SQ1rVRiN5I7Xs0CJdNnhz3SZ2vPmwXnQaTsp5bxTZC5A3ksIvvpLWN84wuOlvWINs8bYZieaQtIhyDkjj0m2VOzNxije9fTazd38YRUycUveBiVMi4M8AAAD___ldpmw">