<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/83765>83765</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
No warning reported for floating point comparison
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mushenoy
</td>
</tr>
</table>
<pre>
Clang doesnt report any warning for floating point comparision, while GCC reports a warning for the same program.
Sample program:
```
struct number { float no; };
int test (struct number *obj) {
if (! obj->no ) {
return 0;
}
return 1;
}
```
Compilation with Clang:
No warnings reported
```
# clang -Wfloat-equal -c prog.c
#
```
Compilation with GCC:
```
# gcc -Wfloat-equal -c prog.c
prog.c: In function test:
prog.c:4:13: warning: comparing floating-point with == or != is unsafe [-Wfloat-equal]
4 | if (! obj->no ) {
| ^
```
Compiler Versions:
```
clang version 16.0.6
gcc (GCC) 13.2.1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVMFuqzgU_ZrL5irI2BDCgkVCmmo2sxlpZm3AAVfGZmzTqH__ZKCkqV773osiYuNzj4_PuTF3TnZaiBKyE2TniE--N7YcJtcLbd6i2rRvZaW47rA1wmmPVozGeuT6DW_caqk7vBqLV2W4D5PRSO2xMcPIrXTSaKAV3nqpBD5X1VrukD9U-16g44PA0ZrO8iEGcgZyXJ7_8GFU2xKw9TXsyfqdp87bqfGop6EWFiE_LZJQG2AnhPwM7PSRNaj0wnkEevhUS4-mfgFaBJYFjOtHXgMcaIKmftkBe9IGH4FW-MlqJNtu76VBwcOLFZncdb0jPp1seVZmGKXiXhqNN-l7nFPZ3PjbvBvqVo9F-3M2yrCZA939Nzu0E_9PXOGumR2Omw32J2Keq-qrYMKGXdN8v906Zkf8S-N10s1MHfLZaDdICuyYsIBdTxyGa8OFflo7cbd04iwP2BnYGU0INwkj6XDSjl8FQnZ6UAbZh5xShLzC309_TfpeMs-zp19aKSz-K2z4u7ivfFxCe11QmOxjEu9xWQr2Aj2EEGiBCYtpnHziiNqStQUreCTKJCdFxkjB0qgvac0yltfXjBQHktZMMJLned7u84TUSZtFsqSEpoSRlGQpTdI4zfZUFKxJiqxoE1JDSsTApYqVeh1iY7tIOjeJ8sDyfRYpXgvl5vuFUi1uOC8CpeG6sWWo2dVT5yAlSjrv7ixeeiXKe2Nvff3dhWN0NFlV9t6Ps5P0AvTSSd9PddyYAegl8K8_u9GaF9F4oJdZlQN6mVX_CAAA__--cXhS">