bug-gnulib
[Top][All Lists]
Advanced

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

Re: clang-10 warning in hash.c


From: Bruno Haible
Subject: Re: clang-10 warning in hash.c
Date: Mon, 27 Jan 2020 14:09:50 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-171-generic; KDE/5.18.0; x86_64; ; )

Hi Tim,

> Not sure if the compiler is correct here, but maybe worth a look:
> 
> hash.c:549:11: error: implicit conversion from 'unsigned long' to
> 'float' changes value from 18446744073709551615 to 18446744073709551616
> [-Werror,-Wimplicit-int-float-conversion]
>       if (SIZE_MAX <= new_candidate)
>           ^~~~~~~~ ~~
> /usr/include/stdint.h:227:22: note: expanded from macro 'SIZE_MAX'
> #  define SIZE_MAX              (18446744073709551615UL)
>                                  ^~~~~~~~~~~~~~~~~~~~~~

This warning is pointless, because
  - Since the next float below 18446744073709551616 = 0x10000000000000000
    would be                   18446742974197923840 =  0xFFFFFF0000000000
    the comparison result is the same for the two values ...615 and ...616.
  - The compiler inserts the implicit conversion only because of the '<='
    operator.
IMO you should file a ticket with the clang people.

Inserting a cast to 'double'

  if ((double) SIZE_MAX <= (double) new_candidate)

would not help, because
the next double-float below 18446744073709551616 = 0x10000000000000000
would be                    18446744073709549568 =  0xFFFFFFFFFFFFF800

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]