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: Paul Eggert
Subject: Re: clang-10 warning in hash.c
Date: Mon, 27 Jan 2020 12:16:57 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

On 1/27/20 5:09 AM, Bruno Haible wrote:
IMO you should file a ticket with the clang people.

That sounds appropriate.

In the past I've worked around problems like these by writing things like "SIZE_MAX + 1.0f <= new_candidate" instead of "SIZE_MAX <= new_candidate" (partly under the argument that this better matches the mathematical comparison we're actually trying to do), but it sounds like Clang 10 would warn about that too.

Inserting a cast to 'double'

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

would not help

Presumably the Clang folks want us to insert a cast to 'float', e.g., "(float) SIZE_MAX <= new_candidate". However, I dislike casts because they're too powerful.

If there's no way to pacify Clang without casting, then I suggest disabling the warning instead. In GCC, we already disable Clang's -Wswitch, -Wpointer-sign, -Wstring-plus-int and -Wunknown-attributes warnings, and perhaps after Clang 10 comes out we'll disable -Wimplicit-int-float-conversion too. Some diagnostics are just too much trouble to pacify.



reply via email to

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