r202211 - Add -Wabsolute-value, warnings about absolute value functions.
Edoardo P.
ed0.88.prez at gmail.com
Wed Mar 5 15:14:43 PST 2014
Hello,
there's an error when reporting the warning with this C++ code:
#include <cstdlib>
void f()
{
float x = abs(1.f);
(void)x;
}
it reports correctly that 'abs' is wrong, but it suggests to use 'fabsf'
instead. 'fabsf' is defined for C99 and C11, not in C++! Not only that: it
suggests to include <math.h>, a C-style include ...
I thought the way to fix is just replacing it with 'fabs' and include
<cmath>, which appears on the code with the argument of 'abs' replaced with
'-1.', but someone in IRC said it would be better to suggest 'std::abs'.
What do you think?
As a bonus: if you replace 'abs' with 'fabs', it reports an error, but that
would be interesting to suggest including <cmath> or provide a declaration
for 'fabs'.
With regards,
Edward-san
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140306/e6313b26/attachment.html>
More information about the cfe-commits
mailing list