<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Compilers and Termination Revisited</title>
	<atom:link href="http://blog.regehr.org/archives/161/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.regehr.org/archives/161</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 05:34:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Joshua Maurice</title>
		<link>http://blog.regehr.org/archives/161/comment-page-1#comment-1464</link>
		<dc:creator>Joshua Maurice</dc:creator>
		<pubDate>Mon, 22 Nov 2010 20:24:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.regehr.org/?p=161#comment-1464</guid>
		<description>“…if you are a C++ user and you think this behavior is wrong, leave a comment at the bottom of this post or send me an email…”
Aye</description>
		<content:encoded><![CDATA[<p>“…if you are a C++ user and you think this behavior is wrong, leave a comment at the bottom of this post or send me an email…”<br />
Aye</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Smith</title>
		<link>http://blog.regehr.org/archives/161/comment-page-1#comment-1463</link>
		<dc:creator>Richard Smith</dc:creator>
		<pubDate>Mon, 22 Nov 2010 20:22:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.regehr.org/?p=161#comment-1463</guid>
		<description>&quot;The second requirement is the tricky one.  If it is talking about termination of the program running on the abstract machine, then it is vacuously met because our program does not terminate.  If it is talking about termination of the actual program generated by the compiler, then the C implementation is buggy because the data written into files (stdout is a file) differs from the data written by the abstract machine.  (This reading is due to Hans Boehm; I had failed to tease this subtlety out of the standard.)&quot;

Hans Boehm&#039;s interpretation is much, much worse than the one used by compiler vendors: if the termination mentioned in the second requirement is supposed to refer to termination of the actual program, then a conforming implementation is permitted to compile any C code into any machine code it likes, so long as the first and third requirements are met and the resulting program does not terminate.</description>
		<content:encoded><![CDATA[<p>&#8220;The second requirement is the tricky one.  If it is talking about termination of the program running on the abstract machine, then it is vacuously met because our program does not terminate.  If it is talking about termination of the actual program generated by the compiler, then the C implementation is buggy because the data written into files (stdout is a file) differs from the data written by the abstract machine.  (This reading is due to Hans Boehm; I had failed to tease this subtlety out of the standard.)&#8221;</p>
<p>Hans Boehm&#8217;s interpretation is much, much worse than the one used by compiler vendors: if the termination mentioned in the second requirement is supposed to refer to termination of the actual program, then a conforming implementation is permitted to compile any C code into any machine code it likes, so long as the first and third requirements are met and the resulting program does not terminate.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Lance Taylor</title>
		<link>http://blog.regehr.org/archives/161/comment-page-1#comment-1454</link>
		<dc:creator>Ian Lance Taylor</dc:creator>
		<pubDate>Fri, 19 Nov 2010 15:24:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.regehr.org/?p=161#comment-1454</guid>
		<description>I agree that C/C++ compilers should not discard simple infinite loops.  That simply confuses the programmer for little optimization benefit.

I think the more interesting question here is when a compiler is permitted to move instructions across a loop.  If a loop has no side effects, is the compiler permitted to move a side-effecting instruction from after the loop to run before the loop?  Here I&#039;m assuming a loop such that the compiler can not prove how many iterations will run.  It&#039;s easy to imagine that in some cases moving the instruction would give better instruction scheduling and a better result over all if it happens that the loop does not run for long.  However, moving the instruction will give surprising results if the programmer is writing a simple-minded delay loop on an embedded system.

To put it another way, in a real program that is not using loops for timing or to wait for some sort of signal, moving the instruction is on average better.  But there are unusual but plausible programs which will break if the instruction is moved.

I think the standard permits the instruction to be moved.  These issues do not arise in most other languages which run farther from the hardware.</description>
		<content:encoded><![CDATA[<p>I agree that C/C++ compilers should not discard simple infinite loops.  That simply confuses the programmer for little optimization benefit.</p>
<p>I think the more interesting question here is when a compiler is permitted to move instructions across a loop.  If a loop has no side effects, is the compiler permitted to move a side-effecting instruction from after the loop to run before the loop?  Here I&#8217;m assuming a loop such that the compiler can not prove how many iterations will run.  It&#8217;s easy to imagine that in some cases moving the instruction would give better instruction scheduling and a better result over all if it happens that the loop does not run for long.  However, moving the instruction will give surprising results if the programmer is writing a simple-minded delay loop on an embedded system.</p>
<p>To put it another way, in a real program that is not using loops for timing or to wait for some sort of signal, moving the instruction is on average better.  But there are unusual but plausible programs which will break if the instruction is moved.</p>
<p>I think the standard permits the instruction to be moved.  These issues do not arise in most other languages which run farther from the hardware.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Abrahams</title>
		<link>http://blog.regehr.org/archives/161/comment-page-1#comment-1452</link>
		<dc:creator>Dave Abrahams</dc:creator>
		<pubDate>Thu, 18 Nov 2010 19:34:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.regehr.org/?p=161#comment-1452</guid>
		<description>Wow; excellent article.  Definitely that behavior is wrong—the surprise can&#039;t possibly be worth any optimizations it enables!  I think, though, this is actually a case of “worse is worse.”</description>
		<content:encoded><![CDATA[<p>Wow; excellent article.  Definitely that behavior is wrong—the surprise can&#8217;t possibly be worth any optimizations it enables!  I think, though, this is actually a case of “worse is worse.”</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin B.</title>
		<link>http://blog.regehr.org/archives/161/comment-page-1#comment-1451</link>
		<dc:creator>Martin B.</dc:creator>
		<pubDate>Thu, 18 Nov 2010 13:16:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.regehr.org/?p=161#comment-1451</guid>
		<description>“…if you are a C++ user and you think this behavior is wrong, leave a comment at the bottom of this post or send me an email…”
Aye!   (... Or should I say &#039;Ow!&#039;?)</description>
		<content:encoded><![CDATA[<p>“…if you are a C++ user and you think this behavior is wrong, leave a comment at the bottom of this post or send me an email…”<br />
Aye!   (&#8230; Or should I say &#8216;Ow!&#8217;?)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

