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]
Other format: [Raw text]

Re: gcc doesn't warn that (unsigned > 0) is always true


Daniel Jacobowitz <drow@mvista.com> writes:

> > void a_loop (unsigned int in) {
> >   do {
> >   } while (--in > 0);
> 
> That is not an endless loop.  in == 0 will terminate it.

Other compilers warn about it, however, and the warning could easily
be avoided by using !=. So I think the warning would be sensible.

-- 
	Falk


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