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
_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to