public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/37038]  New: Bogus warning from GCC
@ 2008-08-06 14:49 sam at gcc dot gnu dot org
  2008-08-06 14:50 ` [Bug ada/37038] " sam at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: sam at gcc dot gnu dot org @ 2008-08-06 14:49 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1372 bytes --]

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-10-06 11:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-06 14:49 [Bug ada/37038] New: Bogus warning from GCC sam at gcc dot gnu dot org
2008-08-06 14:50 ` [Bug ada/37038] " sam at gcc dot gnu dot org
2008-08-06 15:40 ` sam at gcc dot gnu dot org
2008-08-06 15:46   ` Andrew Thomas Pinski
2008-08-06 15:47 ` pinskia at gmail dot com
2008-08-06 16:58 ` sam at gcc dot gnu dot org
2008-08-10 20:18 ` pinskia at gcc dot gnu dot org
2008-08-10 20:32 ` sam at gcc dot gnu dot org
2008-08-10 20:36 ` pinskia at gcc dot gnu dot org
2008-08-10 20:36 ` pinskia at gcc dot gnu dot org
2009-10-06 11:37 ` sam at gcc dot gnu dot org
2009-10-06 11:37 ` sam at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).