Paul Eggert wrote: > 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"
This may deserve a warning that adding 1.0f does not change the value. > 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. And I dislike it because the transformation is correct only if (float) SIZE_MAX >= SIZE_MAX. In the other case, (float) SIZE_MAX < SIZE_MAX, the transformation is incorrect [think of the particular value new_candidate = (float) SIZE_MAX]. The compiler should make correct transformations of comparisons; that's not the job of the programmer. > If there's no way to pacify Clang without casting, then I suggest > disabling the warning instead. I agree. When a compiler makes a normal and correct optimization, we don't want to hear about it. Only when the compiler makes a dangerous optimization, we want to see a warning. Bruno