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: unassig...@gcc.gnu.org
        ReportedBy: j...@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)

Reply via email to