From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9482 invoked by alias); 6 Aug 2008 14:49:00 -0000 Received: (qmail 9211 invoked by uid 48); 6 Aug 2008 14:47:36 -0000 Date: Wed, 06 Aug 2008 14:49:00 -0000 Subject: [Bug ada/37038] New: Bogus warning from GCC X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "sam at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg00410.txt.bz2 With trunk GCC, SVN revision 138798. The following program (t.adb), when compiled with "gcc -O2", gives: t.adb: In function ‘T’: t.adb:6: warning: comparison always false due to limited range of data type (probably emitted by the backend as "-gnatv" doesn't show the caret position) Note that the warning points onto the line containing 'Pos, not the comparison itself. And this is bogus, as if "X" contains "2#11xxxxxx#" (two high bits set), then right shifting it by 6 positions (it is unsigned) will give "3", which corresponds to "White". Moreover, despites the warning, the generated code is correct and returns "0" when the two high bits are set and "1" otherwise. with Interfaces; use Interfaces; function T (X : Unsigned_8) return Integer is type Color is (None, Red, Blue, White); V : constant Color := Color'Val (Shift_Right (X, 6)); begin if V = White then return 0; else return 1; end if; end T; -- Summary: Bogus warning from GCC Product: gcc Version: 4.4.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: ada AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sam at gcc dot gnu dot org GCC host triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37038