Why Is Comparing if an Unsigned Int >= 0 a “Pointless Comparison”?

后端 未结 10 1761
情话喂你
情话喂你 2021-02-12 10:44

I got warning:

Pe186 \"Pointless comparison of unsigned int with zero\"

when I tried to compile the following code:



        
10条回答
  •  悲哀的现实
    2021-02-12 11:07

    You should remove = in

    clLoop >= 0
    

    Let's say your cpLoopStart is 5.

    Then, clLoop value in the further iteratiosn would be -

    clLoop = 4;
    clLoop = 3;
    clLoop = 2;
    clLoop = 1;
    clLoop = 0;
    clLoop = 0;
    clLoop = 0;
    clLoop = 0;
    |
    |
    |
    Infinite times.
    

提交回复
热议问题