Open dbc7d0cf-60de-4ba2-bc9a-c1b7219315df opened 4 years ago
In more testing, I do get error messages if both arguments to isless() are int or both are a complex floating point type.
Perhaps a warning (that it is undefined) would be enough for the mixed int and float.
This rule is not in a Constraints section, and has an attached footnote that goes on to say: "If any argument is of integer type, or any other type that is not a real floating type, the behavior is undefined." So this doesn't seem to be a conformance issue.
So instead this is an extension, and appears to be an incredibly common one: at least GCC's builtin, ICC's implementation of that builtin, Clang's implementation of that builtin, glibc's implementation, uclibc's implementation, musl's implementation, and the MSVCRT
Given the above, do you still think it would be worthwhile for us to diagnose this not-strictly-conforming code under -pedantic-errors? I'm not opposed, but it's not clear that doing so has utility. Perhaps a better course would be to suggest to WG14 that the usual arithmetic conversions should be performed and shall result in a real floating point type, which seems to largely match what implementations actually do.
Perhaps a better course would be to suggest to WG14 that the usual arithmetic conversions should be performed and shall result in a real floating point type, which seems to largely match what implementations actually do.
+1 to this suggestion -- WG14 should standardize existing practice here, if possible. I would consider this to be a pretty low-quality pedantic warning unless there was a runtime issue stemming from it.
Extended Description
Using clang 10.0.0 on ARM (and I believe Intel x86) with -std-c2x -pedantic-errors is not flagging invalid code that uses any of the comparison operators (isless, islessequal, isgreater, isgreaterequal, ...) along with an argument that is not a real floating type. The C standard, since C99, has the requirement: In the synopses in this subclause [Comparison macros], real-floating indicates that the argument shall be an expression of real floating type. There is not even a warning.