[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
g++ bug
From: |
Ron Lancaster |
Subject: |
g++ bug |
Date: |
Mon, 18 Nov 2002 16:05:43 -0500 |
The following code generates an error message saying that the condition is
always true but, for the data here, the condition is false and No is printed.
The compiler is running under Solaris and the version is
gcc version 2.95.3 20010315 (release)
The error message is
---
test.cpp: In function `int main()':
test.cpp:9: warning: comparison is always true due to limited range of data type
---
The program illustrating the problem is:
#include <iostream>
using std::cout;
using std::endl;
int main()
{
unsigned short IR = 0x7000;
if((IR >= 0x0000 && IR <= 0x6FFF) || (IR >= 0x8FFF && IR <= 0xEFFF))
cout << "Yes";
else
cout << "No";
cout << endl;
}
---------------------------------------------
Ron Lancaster
Department of Computer Science
Bowling Green State University
Bowling Green, Ohio 43403-0214
419-372-8697, FAX 419-372-8061
http://www.cs.bgsu.edu/rlancast/
- g++ bug,
Ron Lancaster <=