[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: g++ bug
From: |
Ben Elliston |
Subject: |
Re: g++ bug |
Date: |
19 Nov 2002 10:49:22 +1100 |
User-agent: |
Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Cuyahoga Valley) |
>>>>> "Ron" == Ron Lancaster <address@hidden> writes:
Ron> The following code generates an error message saying that the
Ron> condition is always true but, for the data here, the condition
Ron> is false and No is printed. The compiler is running under
Ron> Solaris and the version is gcc version 2.95.3 20010315
Ron> The error message is --- test.cpp: In function `int main()':
Ron> test.cpp:9: warning: comparison is always true due to limited
Ron> range of data type
Ron> unsigned short IR = 0x7000;
[...]
Ron> if((IR >= 0x0000 && IR <= 0x6FFF) || (IR >= 0x8FFF && IR <= 0xEFFF))
The warning (not an error) message pertains strictly to the first
subexpression in your if expression: (IR >= 0x0000). Because IR is
unsigned, it is always true that IR >= 0.
Consider rewriting as:
if ((IR < 0x6FFF) || (IR >= 0x8FFF && IR < 0xEFFF))
{ .. }
Cheers, Ben
- g++ bug, Ron Lancaster, 2002/11/18
- Re: g++ bug,
Ben Elliston <=