This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12963] New: Wrong and misleading warning encourages writing non-portable code
- From: "bagnara at cs dot unipr dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Nov 2003 13:42:21 -0000
- Subject: [Bug c++/12963] New: Wrong and misleading warning encourages writing non-portable code
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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