public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/23587] New: Missing "warning: comparison is always false due to limited range of data type"
@ 2005-08-27  0:15 v dot haisman at sh dot cvut dot cz
  2005-08-27  0:22 ` [Bug c/23587] " pinskia at gcc dot gnu dot org
  2005-08-27  2:29 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 7+ messages in thread
From: v dot haisman at sh dot cvut dot cz @ 2005-08-27  0:15 UTC (permalink / raw)
  To: gcc-bugs

The following test warns about the comparison being always true only for two of
 the six tests:

#include <cstdlib>

void a (unsigned char x)
{
  if (x < 0)
    abort ();
}

void b (unsigned short x)
{
  if (x < 0)
    abort ();
}

void c (unsigned int x)
{
  if (x < 0)
    abort ();
}

void d (unsigned long x)
{
  if (x < 0)
    abort ();
}

void e (unsigned long long x)
{
  if (x < 0)
    abort ();
}

void f (size_t x)
{
  if (x < 0)
    abort ();
}


wilx@logout:::~/tmp> g++ -save-temps -fverbose-asm -O3 -c test.cxx
test.cxx: In function 'void a(unsigned char)':
test.cxx:5: warning: comparison is always false due to limited range of data type
test.cxx: In function 'void b(short unsigned int)':
test.cxx:11: warning: comparison is always false due to limited range of data type


wilx@logout:::~/tmp> g++ -v
Using built-in specs.
Target: i386-unknown-freebsd4.10
Configured with: ../srcdir/configure --disable-nls
--enable-version-specific-runtime-libs --enable-dwarf2 --with-cpu=pentium3
--with-arch=pentium3 --with-system-zlib --disable-shared --prefix=/home/4/wilx
--enable-languages=c,c++,objc,ada --disable-sjlj-exceptions
--enable-shared=libstdc++ --enable-shared=libobjc
Thread model: posix
gcc version 4.1.0 20050821 (experimental)

-- 
           Summary: Missing "warning: comparison is always false due to
                    limited range of data type"
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: v dot haisman at sh dot cvut dot cz
                CC: gcc-bugs at gcc dot gnu dot org,v dot haisman at sh dot
                    cvut dot cz
 GCC build triplet: i386-unknown-freebsd4.10
  GCC host triplet: i386-unknown-freebsd4.10
GCC target triplet: i386-unknown-freebsd4.10


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23587


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

* [Bug c/23587] Missing "warning: comparison is always false due to limited range of data type"
  2005-08-27  0:15 [Bug c++/23587] New: Missing "warning: comparison is always false due to limited range of data type" v dot haisman at sh dot cvut dot cz
@ 2005-08-27  0:22 ` pinskia at gcc dot gnu dot org
  2005-08-27  2:29 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-27  0:22 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |c
           Keywords|                            |diagnostic
      Known to work|                            |2.95.3 3.2.3 3.4.0 4.0.0
                   |                            |4.1.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23587


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

* [Bug c/23587] Missing "warning: comparison is always false due to limited range of data type"
  2005-08-27  0:15 [Bug c++/23587] New: Missing "warning: comparison is always false due to limited range of data type" v dot haisman at sh dot cvut dot cz
  2005-08-27  0:22 ` [Bug c/23587] " pinskia at gcc dot gnu dot org
@ 2005-08-27  2:29 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-27  2:29 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |2.95.3 3.2.3 3.4.0 4.0.0
                   |                            |4.1.0
      Known to work|2.95.3 3.2.3 3.4.0 4.0.0    |
                   |4.1.0                       |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23587


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

* [Bug c/23587] Missing "warning: comparison is always false due to limited range of data type"
       [not found] <bug-23587-629@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2007-05-20 20:34 ` manu at gcc dot gnu dot org
@ 2007-05-20 20:43 ` manu at gcc dot gnu dot org
  3 siblings, 0 replies; 7+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-05-20 20:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from manu at gcc dot gnu dot org  2007-05-20 21:42 -------
Fixed for GCC 4.3 (all warnings have been grouped under -Wtype-limits).


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23587


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

* [Bug c/23587] Missing "warning: comparison is always false due to limited range of data type"
       [not found] <bug-23587-629@http.gcc.gnu.org/bugzilla/>
  2005-10-25 20:24 ` pinskia at gcc dot gnu dot org
  2007-01-23 20:15 ` pluto at agmk dot net
@ 2007-05-20 20:34 ` manu at gcc dot gnu dot org
  2007-05-20 20:43 ` manu at gcc dot gnu dot org
  3 siblings, 0 replies; 7+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-05-20 20:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from manu at gcc dot gnu dot org  2007-05-20 21:31 -------
Subject: Bug 23587

Author: manu
Date: Sun May 20 20:29:55 2007
New Revision: 124875

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124875
Log:
2007-05-20  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

        PR middle-end/7651
        PR c++/11856
        PR c/12963
        PR c/23587
        PR other/29694
        * c.opt (Wtype-limits): New.
        * doc/invoke.texi (Wtype-limits): Document it.
        (Wextra): Enabled by -Wextra.
        * c-opts.c (c_common_post_options): Enabled by -Wextra.
        * c-common.c (shorten_compare): Warn with Wtype-limits.

testsuite/
        * gcc.dg/compare6.c: Replace Wall with Wtype-limits.
        * gcc.dg/Wtype-limits.c: New.
        * gcc.dg/Wtype-limits-Wextra.c: New.
        * gcc.dg/Wtype-limits-no.c: New.
        * g++.dg/warn/Wtype-limits.C: New.
        * g++.dg/warn/Wtype-limits-Wextra.C: New.
        * g++.dg/warn/Wtype-limits-no.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Wtype-limits-Wextra.C
    trunk/gcc/testsuite/g++.dg/warn/Wtype-limits-no.C
    trunk/gcc/testsuite/g++.dg/warn/Wtype-limits.C
    trunk/gcc/testsuite/gcc.dg/Wtype-limits-Wextra.c
    trunk/gcc/testsuite/gcc.dg/Wtype-limits-no.c
    trunk/gcc/testsuite/gcc.dg/Wtype-limits.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-common.c
    trunk/gcc/c-opts.c
    trunk/gcc/c.opt
    trunk/gcc/doc/invoke.texi
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/compare6.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23587


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

* [Bug c/23587] Missing "warning: comparison is always false due to limited range of data type"
       [not found] <bug-23587-629@http.gcc.gnu.org/bugzilla/>
  2005-10-25 20:24 ` pinskia at gcc dot gnu dot org
@ 2007-01-23 20:15 ` pluto at agmk dot net
  2007-05-20 20:34 ` manu at gcc dot gnu dot org
  2007-05-20 20:43 ` manu at gcc dot gnu dot org
  3 siblings, 0 replies; 7+ messages in thread
From: pluto at agmk dot net @ 2007-01-23 20:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pluto at agmk dot net  2007-01-23 20:15 -------
*** Bug 29694 has been marked as a duplicate of this bug. ***


-- 

pluto at agmk dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pluto at agmk dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23587


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

* [Bug c/23587] Missing "warning: comparison is always false due to limited range of data type"
       [not found] <bug-23587-629@http.gcc.gnu.org/bugzilla/>
@ 2005-10-25 20:24 ` pinskia at gcc dot gnu dot org
  2007-01-23 20:15 ` pluto at agmk dot net
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-25 20:24 UTC (permalink / raw)
  To: gcc-bugs

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



------- Comment #2 from pinskia at gcc dot gnu dot org  2005-10-25 20:24 -------
t.c: In function ‘void c(unsigned int)’:
t.c:17: warning: comparison of unsigned expression < 0 is always false
t.c: In function ‘void d(long unsigned int)’:
t.c:23: warning: comparison of unsigned expression < 0 is always false
t.c: In function ‘void e(long long unsigned int)’:
t.c:29: warning: comparison of unsigned expression < 0 is always false


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |c


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23587


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

end of thread, other threads:[~2007-05-20 20:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-27  0:15 [Bug c++/23587] New: Missing "warning: comparison is always false due to limited range of data type" v dot haisman at sh dot cvut dot cz
2005-08-27  0:22 ` [Bug c/23587] " pinskia at gcc dot gnu dot org
2005-08-27  2:29 ` pinskia at gcc dot gnu dot org
     [not found] <bug-23587-629@http.gcc.gnu.org/bugzilla/>
2005-10-25 20:24 ` pinskia at gcc dot gnu dot org
2007-01-23 20:15 ` pluto at agmk dot net
2007-05-20 20:34 ` manu at gcc dot gnu dot org
2007-05-20 20:43 ` manu 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).