<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 14, 2018 at 6:50 PM, Aaron Ballman <span dir="ltr">&lt;<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>&gt;</span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Infinite loops are undefined behavior because you&#39;d have to solve the<br>
halting problem in order to determine whether any given code path is<br>
dynamically reachable. So presence of an infinite loop is UB in order<br>
to allow optimizers to generate code assuming the behavior never<br>
occurs.</blockquote><div><br>As soon as you mention the word &quot;optimizer&quot; you are lost.<br><br>Compilers don&#39;t need to solve anything.  All they need to do is to model the<br>abstract machine on the underlying computer.  If the abstract machine executes<br>an infinite loop, so does the computer.  As the programmer wrote it. </div></div></div></div>