public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12963] New: Wrong and misleading warning encourages writing non-portable code
@ 2003-11-08 13:42 bagnara at cs dot unipr dot it
  2003-11-08 21:02 ` [Bug c++/12963] " pinskia at gcc dot gnu dot org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: bagnara at cs dot unipr dot it @ 2003-11-08 13:42 UTC (permalink / raw)
  To: gcc-bugs

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


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

end of thread, other threads:[~2005-06-24 23:10 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-08 13:42 [Bug c++/12963] New: Wrong and misleading warning encourages writing non-portable code bagnara at cs dot unipr dot it
2003-11-08 21:02 ` [Bug c++/12963] " pinskia at gcc dot gnu dot org
2003-11-08 22:44 ` bagnara at cs dot unipr dot it
2003-11-15  8:55 ` pinskia at gcc dot gnu dot org
2003-11-21 15:58 ` pinskia at gcc dot gnu dot org
2003-11-21 21:13 ` bagnara at cs dot unipr dot it
2003-11-21 21:52 ` bangerth at dealii dot org
2003-11-21 21:52 ` bangerth at dealii dot org
2003-11-21 23:16 ` gdr at integrable-solutions dot net
2003-11-21 23:52 ` jsm at polyomino dot org dot uk
2004-09-20 13:12 ` bagnara at cs dot unipr dot it
2004-09-20 16:29 ` giovannibajo at libero dot it
2004-09-20 23:08 ` jsm at polyomino dot org dot uk
2004-09-21  7:24 ` abramobagnara at tin dot it
2004-09-22 22:24 ` jsm at polyomino dot org dot uk
2005-03-20 17:50 ` pinskia at gcc dot gnu dot org
2005-03-20 19:10 ` [Bug middle-end/12963] " qrczak at knm dot org dot pl
2005-03-21  0:24 ` pinskia at gcc dot gnu dot org
2005-06-24 23:10 ` pinskia 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).