Re: [PATCH 2/2] util: Cast to 'long double' when calling isnan()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 02, 2017 at 07:15:31PM +0100, Andrea Bolognani wrote:
Clang 3.9 chokes when calling isnan() on a double variable:

 util/virxml.c:153:21: error: implicit conversion increases
                       floating-point precision: 'double' to
                       'long double' [-Werror,-Wdouble-promotion]
         (isnan(obj->floatval))) {
          ~~~~~~~~~~~^~~~~~~~~
 /usr/include/math.h:360:46: note: expanded from macro 'isnan'
 #  define isnan(x) __MATH_TG ((x), __isnan, (x))
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
 /usr/include/math.h:295:16: note: expanded from macro '__MATH_TG'
    : FUNC ## l ARGS)
      ~~~~~~~~~ ^~~~

Note how the wrong version of isnan() is being called: isnanl()
is for 'long double's, but obj->floatval is a double and a
suitable version should be called instead.


I don't know where do you see that ^^.  Good eyes, I guess =)

Cast the value to 'long double' to make the compiler happy.
---
Clang seems to be tripping on the specific way the isnan()
macro is defined in recent glibc versions; more specifically,
if I replace the current definition in <math.h> with the one
that predates the introduction of the __MATH_TG() macro, I
can get the current code to compile. I was not able to find
anything wrong with the __MATH_TG() macro though.


This sounds like a glibc <=> clang problem that we shoudn't introduce
more complexity for.  Also *I* don't see this error, for a change =)


Martin

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux