<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/111013>111013</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] readability-implicit-bool-conversion emits useless fixit for comparisons in C
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug,
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
5chmidti
</td>
</tr>
</table>
<pre>
In C, the result of a comparison is defined as returning a `1` or a `0` of type `int` (C N3220 6.5.9.7 & 6.5.10.4).
https://godbolt.org/z/fTErfvzqW
```C++
bool foo() { return 1 != 0; }
```
```
[<source>:1:21: warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]](javascript:;)
1 | bool foo() { return 1 != 0; }
| ^
| ( ) != 0
1 warning generated.
```
The check should probably be adapted to check if the source expression of the cast is a comparison (ignoring parens), and just add a cast instead.
Additionally, a new option could be added to ignore the conversion warning in this case for C.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVEGv4yYQ_jXjyygWHsexffAhcV6kXnpaqWdscMwrARdwdrO_vgLnNdvVa9VaCJiBb_jmYwz3Xl2NlB1UJ6jOGV_DbF1XjfNNiaCywYpH94vBHqjHMEt00q86oJ2Q42hvC3fKW4PKo5CTMlIg9-hkWJ1R5ooc4cAKODC0bjNYMiYMj0VGW5kQPUBNj7-WRAwPeZW3eY1AhzQvWL4HanMEdgZ23Po5hMVDeQS6AF2uVgxWh9y6K9DlO9Bl-vLmpvv3P377EQQHtrUe6BRb8g7WapysBWqAWoT69EwACwQqoDwjg_KEUJ9_CvNp7KdZnaDsvV3dKKF8g_JYQHmM0Y74lSdx4lTdFq1GFXC05i6dV9YgUB1FoRp3UL5FMzKMNlQnJ7ngg9IqPHYf4F1c370iQHWOjZp3fud-dGoJUanyBNRu7GJmdY__O3NMX4R-9kH1to3b3n_cRs1zbF-nJEjxIQ1epZGOBynyf5H8yyxxnOX4O_rZrlrg4uzAB_3AQSIXfAlSYLDPPWpKBbxdCcpvi5M-6W23hZH7EOv4b3UN1KirsS5yWriTxkcNqUduBL6vPiAXIkIS2Pgg-V-UU38UQgVlDdf6kXBo5Fe0S_ThmFgnsmKjmg6TG59XRXyoogyGWfl4msTJOuzzTHSlaMuWZ7IraqrbmlhbZnM31gdeyoaNYj9x3ozFnrF2XzQVHZpJVFWmOmK0Lxgri0OxryivqG6rUQys5A0bGIc9kzeudK71_RZ_rUx5v8quKApWlJnmg9Q-PRxEw3oFIqAeiEbNzXUXlHhEV3XOXBcj7Ib16mHPtPLBv2IGFXR6fn6AVWf8L3WO8qaCx9VLLb3HSX1TIcnyukAfNeuz1enupxdDhXkd8tHegC6RzHPYLc6-yzEAXVK2HujyTPje0Z8BAAD___5Hicw">