From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13840 invoked by alias); 8 Nov 2003 13:42:22 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 13832 invoked by uid 48); 8 Nov 2003 13:42:21 -0000 Date: Sat, 08 Nov 2003 13:42:00 -0000 From: "bagnara at cs dot unipr dot it" To: gcc-bugs@gcc.gnu.org Message-ID: <20031108134219.12963.bagnara@cs.unipr.it> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/12963] New: Wrong and misleading warning encourages writing non-portable code X-Bugzilla-Reason: CC X-SW-Source: 2003-11/txt/msg00603.txt.bz2 List-Id: 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