This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

warning: comparison is always true due to limited range of data type


Hello.

There was a discussion about this warning about a year ago, but it
seems to have been forgotten without a resolution.

This warning is issued unconditionally, impossible to disable, hard
to work around, and it depends on integer sizes even when the code
is portable.

I think it should be removed altogether, or at least disabled by
default, or at least possible to disable.

I have macros which generate code like this:
   if ((x >= 0 || x >= -0x40000000) && x < 0x3FFFFFFF) ...
where the type of x is only know to be an integer type.
It correctly checks whether the value lies within the interval
-0x40000000..0x3FFFFFFF, but generates the mentioned warning if
the type alone is sufficient to determine the answer on the given
architecture. I don't care whether it's true because of the type
or because of the actual value. Please let the warning to away.

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak@knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]