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++/11490] New: [3.4 regression] Spurious signedness warning with templates


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: [3.4 regression] Spurious signedness warning with
                    templates
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P1
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bangerth at dealii dot org
                CC: gcc-bugs at gcc dot gnu dot org

For this code
-------------------------
template <int N> bool f() {
  unsigned int i=0;
  return i!=N;
}

template bool f<2> ();
-------------------------
we did not get warnings in the comparison i!=N, but we do now:
tmp/gg> ../build-gcc/gcc-install/bin/c++ -c x.cc -W
x.cc: In function `bool f()':
x.cc:3: warning: comparison between signed and unsigned integer expressions

This must have crept in in the last two or three days, since my nightly
builds with -W -Werror succeeded until 2003-07-07. It's not present on
the 3.3 branch.

Now, it's certainly arguable whether this warning is justified, after all
i is unsigned, and N is signed. However, if the warning were postponed
until instantiation time, the exact value of N were known, and in this
case one could check whether N is really negative, or if it is in fact
positive.

I personally would appreciate if this would be handled quickly, since it
hits our code at several 100 places :-(

W.


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