[Bug c++/12963] New: Wrong and misleading warning encourages writing non-portable code
bagnara at cs dot unipr dot it
gcc-bugzilla@gcc.gnu.org
Sat Nov 8 13:42:00 GMT 2003
For the C++ function
unsigned char
foo(unsigned char c) {
if (c <= 255)
return 255;
else
return c;
}
g++ 3.4 20031102 (and also 3.3.2, but NOT 3.3.1) generates,
without any -W option, the following warning:
g++ -c bug.cc
bug.cc: In function `unsigned char foo(unsigned char)':
bug.cc:3: warning: comparison is always true due to limited range of data type
I believe this warning should not be issued, since unsigned chars may
be more than 8 bits wide. The fact that in the particular implementation
of ISO C++ I am using right now unsigned chars are 8 bits wide should be
irrelevant (I certainly do not want to write unportable code to avoid that warning).
--
Summary: Wrong and misleading warning encourages writing non-
portable code
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bagnara at cs dot unipr dot it
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12963
More information about the Gcc-bugs
mailing list