| Issue |
170596
|
| Summary |
[clangd] readability-implicit-bool-conversion false positive with bool and logical operators in C23
|
| Labels |
false-positive
|
| Assignees |
|
| Reporter |
Chase-san
|
The `readability-implicit-bool-conversion` check incorrectly warns about implicit `bool` -> `int` conversion when using `bool` values with the `&&` operator, even though both operands are scalar types and this is perfectly valid C.
The warning message is misleading - it suggests a type safety issue when this is actually just normal operation of the && operator. If the intent is to enforce a style preference for explicit comparisons, the warning should clearly state that rather than implying a conversion problem.
This only occurs when clangd is set to "-std=c23".
## Expected Behavior
No warning should be issued. The C standard explicitly states that && accepts any scalar type, and bool is a scalar type. There is no implicit conversion issue here.
## Actual Behavior
"Warning: Implicit conversion 'bool' -> 'int'" on the returns_bool() call when used with &&.
## Environment
clangd version: 21.1.4
C standard: C23
Platform: windows
## Example Code
```c
bool returns_bool(void) { return true; }
void test(size_t len) {
// NO WARNING - bool used directly in condition
while (returns_bool()) {}
// WARNING: "Implicit conversion 'bool' -> 'int'"
while ((len > 0) && returns_bool()) {}
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs