知乎上,有一个经典问题讨论非常火热。
没啥区别党:都是心理作用
#include<stdio.h>int main(){for(;;){printf("for\n");}}
#include<stdio.h>int main(){while(1){printf("while\n");}}
正方观点:哪有好的编译器
label:……mov a, #1jnz label
反方观点:这种代码过时了
GJB 8114-2013 R-1-9-4:无限循环必须使用while(1)语句,禁止使用for(;;)等其他形式
CppCoreGuidelines ES.73:Prefer a while-statement to a for-statement when there is no obvious loop variable
360 safe rules: for语句没有明确的循环变量时应改用while句语
工程师实地测试:和编译器和优化有关
参考文献

