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.