This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/49426] New: unwarranted warning from -Wsign-compare


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

           Summary: unwarranted warning from -Wsign-compare
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jim@meyering.net


In the following function, the compiler can deduce that "c"
is positive when it is compared with "k", so should not emit a warning:

$ cat k.c
int
f (int c, unsigned int k)
{
  if (c < 0)
    return -1;
  return c < k;
}
$ gcc -c -O2 -Wsign-compare k.c
k.c: In function 'f':
k.c:6:12: warning: comparison between signed and unsigned integer expressions
[-Wsign-compare]

Using built-in specs.
COLLECT_GCC=/p/bin/gcc
COLLECT_LTO_WRAPPER=/h/p/p/gcc-2011-06-14.11h16/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /h/j/w/co/gcc-svn/configure --prefix=/p/p/gcc-2011-06-14.11h16
--disable-multilib --disable-libmudflap --disable-nls --enable-languages=c
Thread model: posix
gcc version 4.7.0 20110613 (experimental) (GCC)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]