<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 14, 2018 at 2:23 PM, Lawrence Crowl <span dir="ltr">&lt;<a href="mailto:Lawrence@crowl.org" target="_blank">Lawrence@crowl.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On 3/14/18, Hyman Rosen &lt;<a href="mailto:hyman.rosen@gmail.com">hyman.rosen@gmail.com</a>&gt; wrote:<br>
</span><span class="gmail-">&gt; On Mar 14, 2018, Lawrence Crowl &lt;<a href="mailto:Lawrence@crowl.org">Lawrence@crowl.org</a>&gt; wrote:</span><br>
Second, and most imporant, C&#39;s pointer and array model enabled<br>
programmers to write in source code the kinds of optimizations that<br>
compilers of the day were not doing.  In particular, compilers were<br>
not doing strength reduction in loops.  In practice, a C program<br>
could run in half the time of a Pascal program.  Consequently, the<br>
need for using assembler was lower, which avoided the significant<br>
cost of writing in assembler.  That optimization ability is exactly<br>
why C became popular.<br></blockquote><div><br>Notice that this is an optimization <i>written by the programmer</i>.<br><br>The most popular quote about C back in the day was &quot;trust the programmer.&quot;<br>The notion that parts of a program should be ignored because the compiler<br>decides their behavior is undefined and therefore don&#39;t run is antithetical to that.<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
The language has undefined behavior because it was targeted to systems<br>
in which instruction sets did radically different things.</blockquote><div><br>But each of those systems did <i>something</i>.  The compiler world generate the<br>obvious (remember, transparency) instructions corresponding to the code,<br>and the program would get whatever the result was.  There was never a<br>notion that undefined behavior gave the compiler permission to act as if the<br>program never executed undefined behavior.<br><br>As usual, Ada was on top of this.  Ada95 defined the concept of <a href="http://www.adaic.org/resources/add_content/standards/95rat/rat95html/rat95-p2-1.html#4">bounded error</a>:<font face="arial, helvetica, sans-serif"><i><span style="color:rgb(0,0,0);font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br>The general idea is that the behavior is not fully determined but nevertheless<br>falls within well-defined bounds.</span></i></font><br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Compiler writers are often under intense pressure to squeeze more<br>
performance out of programs.  They have made legal code faster at the<br>
expense of illegal programs.  In doing so, they did not change the<br>
language.  On the surface, that is reasonable.  The major problem was<br>
that they started performing an entirely new class of optimizations<br>
without warning anyone.</blockquote><div><br>The fundamental error is claiming that undefined behavior constitutes an<br>&quot;illegal program&quot;, or rather, that behavior which may not be definable in the<br>same way in every environment should constitute an illegal program.  It&#39;s<br>my contention that the optimizationist sect of compiler writers are the people<br>who pushed for making such unportable programs illegal to begin with.<br><br>I have no sympathy for people who press to get the wrong answer faster.<br>It&#39;s the patricide asking for mercy as an orphan here.</div></div></div></div>