With OpenWatcom we (a colleague and myself) receive the following warning:
Warning! W124: Comparison result always 0
The code we have is of course part of a larger project, but the piece of code that results in a warning is equivalent to this:
typedef unsigned __int64 uint64_t; /* typedef'd depends on compiler/platform */
uint64_t x;
/* x gets a value */
if (x > 0xFFFFFFFFU) /* <-- warning */
{
/* do something */
}
I would think that the literal value should be promoted to the integer type of x
, but evidently it isn't.
What gives? Do integer promotion rules not apply to 64bit integers?
Are the only solutions an explicit cast ((x > (uint64_t)0xFFFFFFFFU)
) or something ala comparison to 0xFFFFFFFFULL
? The typecast will actually make the warning vanish, but I didn't look at the produced code to verify that it still makes sense.
Notes:
- The code does not compile as C99, it uses something between C89 and C99 (e.g. includes C++ style single-line comments).
- Watcom and OpenWatcom are just compilers used by some of our team members and OpenWatcom was the only compiler to complain there.