comparisons..

Andrew Morton andrewm@uow.edu.au
Thu Jul 13 17:12:00 GMT 2000


Gerald Pfeifer wrote:
> 
> On Thu, 13 Jul 2000, Andrew Morton wrote:
> > Unfortunately using `-W' in the kernel makefiles generates a truckload
> > of warnings.  Is there a way of unbundling the `if (unsigned < 0)'
> > warning with a standalone flag?
> 
> The questions is: Are the other warnings warranted or not? :-)

It generated nine megs of warnings total!

Yes, a lot were warranted, but not really practical.

The most useful ones were:

comparison of unsigned with zero:
	(unsigned < 0)
	(unsigned >= 0)

The empty `if' check found several of these:
	if (some_condition);
		statement;

comparisons like X<=Y<=Z do not have their mathematical meaning
	This happened rarely and was 100% correlated with wrong code.


> You already found several bugs in the kernel, perhaps there are further
> ones still in there? And, of course, if you receive warnings you consider
> inappropriate (bugs in the compiler?), please let us know!

There are probably some bugs hiding behind "comparison between signed
and unsigned", but I didn't check these - there were many hundreds.

  I'm told that the compiler will warn for this code:

	unsigned int i;
        if (i > 5)      /* 'i' is unsigned, '5' is signed, so warn */

  which makes this warning hard to use more than occasionally.


More information about the Gcc mailing list