On Tue, Nov 13, 2012 at 11:23 PM, Shuxin Yang <span dir="ltr"><<a href="mailto:shuxin.llvm@gmail.com" target="_blank">shuxin.llvm@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Hi, All:<br>
<br>
    Is it legal to delete empty infinite loop like this : "while(1) {}"?<br>
It is interesting that both llvm and gcc keep the loop, however Open64 delete it.<br></blockquote><div><br></div><div>Well, LLVM *sometimes* keeps infinite loops. Compile this with -O2, for example:</div><div><br></div>
<div class="gmail_quote">
<div><div>void bar(void) {</div><div>  for (;;) {}</div><div>}</div><div><br></div><div>void foo(void) {</div><div>  bar();</div><div>}</div></div><div><br></div><div>Infinite loops really are special, and infinite loops containing no side effects really are especially special. People will probably say that LLVM and Open64 and other compilers have bugs here, and they're probably right. There is room for sympathy though, both because of the unique havoc infinite loops play on compiler theory, and because of how rarely empty loops are actually an advisable idiom in the real world.</div>


<div><br></div><div>Dan</div></div><div><br></div></div>