<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62123>62123</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] False positive with cppcoreguidelines-narrowing-conversions from a comparison operator.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
brackeen
</td>
</tr>
</table>
<pre>
On macOS, the `BOOL` type is a `signed char`, which results in some narrowing conversion warnings.
test.c:
```c
typedef signed char BOOL;
BOOL foo(int i) {
BOOL result = (i == 0);
return result;
}
```
Running (clang-tidy 16.0.1):
```
clang-tidy -checks=cppcoreguidelines-narrowing-conversions test.c
```
Result:
```console
test.c:4:19: warning: narrowing conversion from 'int' to signed type 'BOOL' (aka 'signed char') is implementation-defined [cppcoreguidelines-narrowing-conversions]
BOOL result = (i == 0);
^
```
In C++, a similar warning:
```console
test.cc:4:19: warning: narrowing conversion from 'bool' to signed type 'BOOL' (aka 'signed char') is implementation-defined [cppcoreguidelines-narrowing-conversions]
BOOL result = (i == 0);
^
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVN1u4ywUfJrjm6NYGP8lF75omi_SJ60UafcJMD6x2WKwADfK26_wuk22qrpV7zZCCYFhmDMDCO9Vb4gaKPdQHhIxh8G6pnVCPhGZpLXdtTkZHIU8_QD-iGEghIrtT6dvUDEM14lQeRRxcKHqUA7CQcUi-jIoOaAjP-vgURn0diQ0wjl7UaZHac0zOa-swYtwRpnep8AOwB5-fwfyIZWQr38j69LkOn2dqKMz3m2Mi7J8f88Sh_BsLfCtMgEV8B1CvUIQcVmzqkTIDxiBsRP7DPjulS-CHYXZmRV-26k-vNF4r-D7bGJxkVhqYfpNUN0VsyplabbwP9yj31DcrdjIgeSTh_wgp0laR_2sOtLKkN-8urq5uepxdfADaWsd7yuQ1nir6U0aBeQPWVT9klrsvpvq2dkRgdfKBOA1BvuS1XJwgNdLXLyOzognEUfuTxGvY1bKoxonTSOZIIKyZtPRWUUQlPtPGgHl4Yt5__mB8r8PzPzf4CPw_dIeUaBXo9LC3dn0d3-_ZnBrrf4nHf7Y0KRr8m6X70RCTVZts6LIWVUkQ0NMFl3Hdy1VshRttt1Su8vrLa_bs5TnIlENZzxnRVawPM9YkZbUbrd1S5IXktVFAQWjUSidav08ptb1ifJ-pqbiGc8TLVrSfnkWOTd0wWUSOI-vpGvimk079x4KppUP_sYSVNDLe3q7t1Ae8Ci0J5ysV0E9E15UGPCzl3gJWaC04ySc8tagnciJYF2azE43QwiTj4eLH4EfexWGuU2lHYEfo6z1ZzM5-5NkAH5civHAj0uxvwIAAP__ambQCA">