[ofa-general] Re: dealing with gcc 'comparison is always false' warnings
Roland Dreier
rdreier at cisco.com
Wed May 30 08:56:37 PDT 2007
> However, gcc is _just as correct_. It is only crying about seeing a condition
> that the programmer could have written with some purpose in mind but which
> is being completely compiled away by it when generating the code because
> of it being a tautology / contradiction ...
Well, OK, but there's lots of things gcc could warn about. How about
while (1) { ...
By your argument gcc should warn that '1' always evaluates to true.
Or how about
#if 0
why shouldn't the preprocessor warn that the conditional is always false?
> No, shutting gcc up wouldn't be the right thing, IMHO. These warnings are
> a good reminder to the programmer to go and see if there is a real bug
> somewhere and if something really needs to be done with the code (could
> be simply to change the type of a variable to signed that was mistakenly
> declared unsigned, f.e.).
OK, but suppose I looked at it and there's no bug. Leaving the
warning has a cost too: it hides useful warnings (that might be
showing real bugs) in all the clutter.
- R.
More information about the general
mailing list