This is the mail archive of the gcc@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]

Re: constant signed/unsigned comparison warning


Instead of:

  if (i == -1) {
	...
  }
  else if (i < sizeof(foo)) {
	...
  }

what about:

  if (i < 0) {
	...
  }
  else if (i < sizeof(foo)) {
	...
  }

This is at least as clean, and this is something we *could* teach gcc
to recognize.  (It would require some simple range analysis in Gcc,
but that is going to be very desirable anyway.  Some support may
already have been added.)

	--Per Bothner
Cygnus Solutions     bothner@cygnus.com     http://www.cygnus.com/~bothner


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