| Issue |
76817
|
| Summary |
[clang-tidy] `readability-implicit-bool-conversion` incorrectly treats bool bitfield comparison with bool variable
|
| Labels |
clang-tidy
|
| Assignees |
|
| Reporter |
Kaltxi
|
**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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs