[vtk-developers] Dashboard problems: ambiguous conversion fabs() call

Kyle Lutz kyle.lutz at kitware.com
Thu Aug 16 09:39:21 EDT 2012


On Thu, Aug 16, 2012 at 5:30 AM, David Gobbi <david.gobbi at gmail.com> wrote:
> The dashboard has failures on Windows and AIX from the use of fabs()
> in the templated vtkTuple class.  The problem seems to be that
> "#include <math.h>" provide the overloaded c++ fabs() on those
> systems, instead of providing the C fabs().  This problem appeared for
> the first time because the vtkTuple::Compare type is being wrapped,
> which finally causes it to be exercised for integer types.
>
> In order to keep things consistent across platforms, why aren't we
> using the std:: qualifier on these calls?  I.e.:
>
> #include <cmath>
> std::fabs(...)
>
> There are tons of places in VTK where I see things like this:
>
> #include <cmath>
> fabs()
>
> In the latter, it isn't clear whether the coder wants the C fabs() or
> the overloaded C++ std::fabs().

I agree completely. We should prefer the templated C++ functions over
their C counterparts. I hit the same issue in VTK/ParaView with the
usage of C's sqrt()/sqrtf() and replaced them all with C++'s
std::sqrt().

Also, did you mean std::abs()? std::fabs() is not overloaded for the
integral types and std::abs() should be preferred anyway.

> I've pushed a fix for the vtkTuple dashboard issues, could people look
> at both changeset 3 and changeset 4 and let me know which is the
> preferred solution?
>
> http://review.source.kitware.com/#/t/1092/

I'd prefer changeset 4.

-kyle



More information about the vtk-developers mailing list