mardi 6 novembre 2018

c++11 pugixml fpclassify() warning float-converstion from double to float may alter its value

I am using c++11 and using a (or the) pugixml c++ library. I am compiling the pugi files myself (1 .cpp file, and 2 .hpp files).

When using gcc on linux (ubuntu) it builds fine. When I build with a different x-compiler I get warnings (probably due to different architecture / integral sizes).... fair enough so far.

My problem is that I want to fix the warnings because I am using -Werror throughout my code / makefile and I have lots of warnings turned on.

The specific line of code in the pugixml library is as followins (its an ~12k line file):

#elif defined(fpclassify) && defined(FP_NAN)
    return fpclassify(value) == FP_NAN
#else

Where value is a double. The error I get is:

conversion to 'float' from 'double' may alter its value [ -Werror=float-conversion ]

This seems to fix it: return fpclassify(static_cast<float>(value)) == FP_NAN

But what I can't see (other then because the compiler tells me) is what fpclassify() and FP_NAN are. I can see some documentation here and here. It seems to show that there is a version of fpclassify for float and double.... so I am confused as to why there are warnings...

The x-compiler I am using is: arm-poky-linux-gnueabi-gcc version 5.2.0. which seems to support c++11.

I am looking for the reason why I get this warning. I can't really make a minimal example but if there is any further info that would be useful I can post it...

Aucun commentaire:

Enregistrer un commentaire