I got warning:
Pe186 "Pointless comparison of unsigned int with zero"
when I tried to compile the following code:
for(clLoop = cpLoopStart; clLoop >= 0; clLoop--)
{
//Do something
}
I don't understand why. I could understand, if I were looking for a value less than zero, since an unsigned int
can never be negative. But all I am looking for here is if it is equal to zero, which an unsigned int
certainly can be.
I could even see this error if in this loop I tried to pre-decrement instead of post-decrement, but again that is not the case.
You check whether the unsigned int is greater than or equal (>=
) zero. This expression will always be true, because unsigned integers will never be less than zero.
The compiler tries to warn you that you are about to program an infinite loop.