Open Quuxplusone opened 6 years ago
Bugzilla Link | PR38331 |
Status | NEW |
Importance | P enhancement |
Reported by | David Bolvansky (david.bolvansky@gmail.com) |
Reported on | 2018-07-26 10:51:56 -0700 |
Last modified on | 2021-04-15 22:30:43 -0700 |
Version | trunk |
Hardware | PC Linux |
CC | andrew.v.tischenko@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, tdiff@yandex.ru |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
Ok, I checked the code and I see this is disabled by default.
https://github.com/llvm-mirror/clang/blob/2100b0595fd952fab745d8f53e6619ca0c0d06b2/lib/Sema/SemaChecking.cpp#L8104
Maybe we can reconsider that special case?
Or if you are disagree to turn it on for constants - maybe we could add "-
Wfloat-equal-constant" (or similar name) to handle this case (off by default)?
However the same warning is produced if the constant was specified as an
integer:
double f(double x)
{
return x == 0 ? x : -x;
}
<source>:3:14: warning: comparing floating point with == or != is unsafe [-
Wfloat-equal]
return x == 0 ? x : -x;