<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61943>61943</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
-Woverloaded-shift-op-parentheses does not detect issues with implicit cast to bool
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
PiotrZSL
</td>
</tr>
</table>
<pre>
Example:
This one reports -Woverloaded-shift-op-parentheses:
```
#include <iostream>
int main() {
int a = 5;
std::cout << "Test" << a == 5 ? 1 : 0;
return 0;
}
```
warning: overloaded operator << has higher precedence than comparison operator [-Woverloaded-shift-op-parentheses]
But this one not:
```
#include <iostream>
int main()
{
int a = 5;
std::cout << "Test" << a ? 1 : 0;
return 0;
}
```
And this one:
```
#include <iostream>
int main()
{
int a = 5;
std::cout << "Test" << static_cast<bool>(a) ? 1 : 0;
return 0;
}
```
reports: warning: operator '?:' has lower precedence than '<<'; '<<' will be evaluated first [-Wparentheses]
I would expect that all of above report some sort of warning.
This is reported by Sonar as CWE-783: https://cwe.mitre.org/data/definitions/783.html
"Suspicious calculation. Please use parentheses to clarify the code. The code ''a+b?c:d'' should be written as either ''(a+b)?c:d'' or ''a+(b?c:d)''."
This should be handled by some warning, or by some clang-tidy check.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVcGOozgQ_RpzKQURuwnkwKHTGaSV9jBStzTSXlbGLoJ3jY3sojP99ytDMk1rZzWHmcNKEZiy65Xf83NFxmguDrFh5YmV50zONPjQfDaewh_Pv2ed12_Np69ynCwy8ciKMytuz5fBRPAOIeDkA0XYffGvGKyXGvUuDqannZ92kwzoaMCI8R3gUNx-6ycXxik7awQmnoyPFFCOTHzaljOOYJTGMV4zfgRWndY4AECak8DEGUomNvFIOtUUj8rPlLCZeALG-QtGYpzfI0vqkg1MtLAHJh6h-IAUkObgNkFWnb_L5SqDM-6SEN7VAD9hkOTDveIgIwzmMmCAKaBCjU4h0CAdKD9OMpjo3SarPP1Y3PK8les0E9D9hJynX6j9XYBfewA_qfv6fHT6G-v_NeNIkoz6U8lITDx13tu0AV7Lxds_K8btRiaErR-_2YlXTLRpm7xarGj99TtOXJal3S6D04dvuBproUPAV2lnSaihNyHSatX_tuVvcPWz1YBfJ1TJoZJAWgu-B9n513szgehHhJhGvr9zyDd9x8TbStTQvcGzdzKAjPD05dOuqkWiOxBNS8vhLeOtumI-GgqY-3BhvNWSZHphb5wh411kvK1qkQ802rtR-PMcJ6OMnyMoadVsZVqaw2eLMiLMEWHDFciDsjKY_g1oQFBeYw4vt9GiH68k46eOiVYx8ajXEMRhEaVDuAZDhC5RQUOpP6xLVmucumTGj7k-bIAZrzfYx3UiZ5z_q3G_lxyk03aVcVH97hj-lLDvUWWlu-zI6DdQA6q_80w3Qh_FUWbY7A91cajFoaiyoem1KnlR10fc7zUeO65VKfaV1gfVC6zrzDS84KJ4KMqiFoJXeV33_YM8dMe6PMqy4uyhwFEam1v7OqbzykyMMzaH_fFBZFZ2aOPyh8W5wyssk4ljec5Ck3J23XyJ7KGwJlJ8RyFDFpsfdlLQHmPqmaCRkkuXAhGuhgYw42SNMgTp6qYDT3c3m4NtPvrtYmiYu1z5kfE27eD22k3B_4WKGG9XWMbbhdc_AQAA___t-TbD">