Will my compiler ignore useless code?

前端 未结 9 1287
情深已故
情深已故 2021-02-06 21:53

I\'ve been through a few questions over the network about this subject but I didn\'t find any answer for my question, or it\'s for another language or it doesn\'t answer totally

9条回答
  •  情书的邮戳
    2021-02-06 22:07

    In your loop there are two an operation implicit in each iteration. An increment:

    j++;
    

    and comparison

    j

    So, the loop is not empty although it looks like it is. There is something being executed at the end and this is not ignored by the compiler of course.

    This happens also in other loops.

提交回复
热议问题