<?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: Signed Overflow</title>
	<atom:link href="http://www.airs.com/blog/archives/120/feed" rel="self" type="application/rss+xml" />
	<link>http://www.airs.com/blog/archives/120</link>
	<description>Ian Lance Taylor</description>
	<lastBuildDate>Sun, 07 Mar 2010 17:12:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: January 11, 2008 &#171; Everything is Data</title>
		<link>http://www.airs.com/blog/archives/120/comment-page-1#comment-17251</link>
		<dc:creator>January 11, 2008 &#171; Everything is Data</dc:creator>
		<pubDate>Sat, 02 May 2009 00:08:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/120#comment-17251</guid>
		<description>[...] Ian Lance Taylor&#8217;s blog has an interesting post on signed overflow behavior in C. According to the C standard, integer overflow results in undefined behavior, and modern versions of GCC take advantage of this to generate more efficient code. This topic was raised on -hackers by Tom a few years ago &#8212; at the time, only the -fwrapv flag was implemented by GCC. Now that GCC 4.2 provides -Wstrict-overflow, this might be worth investigating further. [...]</description>
		<content:encoded><![CDATA[<p>[...] Ian Lance Taylor&#8217;s blog has an interesting post on signed overflow behavior in C. According to the C standard, integer overflow results in undefined behavior, and modern versions of GCC take advantage of this to generate more efficient code. This topic was raised on -hackers by Tom a few years ago &mdash; at the time, only the -fwrapv flag was implemented by GCC. Now that GCC 4.2 provides -Wstrict-overflow, this might be worth investigating further. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Lance Taylor</title>
		<link>http://www.airs.com/blog/archives/120/comment-page-1#comment-9322</link>
		<dc:creator>Ian Lance Taylor</dc:creator>
		<pubDate>Fri, 11 Jan 2008 15:36:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/120#comment-9322</guid>
		<description>There is no warning about the last example from gcc mainline because gcc doesn&#039;t actually optimize it differently based on undefined signed overflow.  It just goes ahead and generated the overflow code.  I wasn&#039;t clear: I didn&#039;t intend that to be an example of using overflow to optimize, I intended to show a case where -fwrapv differed from -fno-strict-overflow.</description>
		<content:encoded><![CDATA[<p>There is no warning about the last example from gcc mainline because gcc doesn&#8217;t actually optimize it differently based on undefined signed overflow.  It just goes ahead and generated the overflow code.  I wasn&#8217;t clear: I didn&#8217;t intend that to be an example of using overflow to optimize, I intended to show a case where -fwrapv differed from -fno-strict-overflow.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ncm</title>
		<link>http://www.airs.com/blog/archives/120/comment-page-1#comment-9310</link>
		<dc:creator>ncm</dc:creator>
		<pubDate>Thu, 10 Jan 2008 22:53:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/120#comment-9310</guid>
		<description>I see what happened:

$ gcc -O3 -Wstrict-overflow=5 -Wall -c t.c

is not the same as

$ gcc -O3 -Wall -Wstrict-overflow=5 -c t.c

Evidently the -Wall in the first example bumps the warning level back down to 1.  I see that gcc-4.2 warns only about the first example, I suppose because it doesn&#039;t perform that optimization on the next two.  I can&#039;t seem to get a warning about the last example from gcc-4.3.  Shouldn&#039;t I?  It looks like bad code.</description>
		<content:encoded><![CDATA[<p>I see what happened:</p>
<p>$ gcc -O3 -Wstrict-overflow=5 -Wall -c t.c</p>
<p>is not the same as</p>
<p>$ gcc -O3 -Wall -Wstrict-overflow=5 -c t.c</p>
<p>Evidently the -Wall in the first example bumps the warning level back down to 1.  I see that gcc-4.2 warns only about the first example, I suppose because it doesn&#8217;t perform that optimization on the next two.  I can&#8217;t seem to get a warning about the last example from gcc-4.3.  Shouldn&#8217;t I?  It looks like bad code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Lance Taylor</title>
		<link>http://www.airs.com/blog/archives/120/comment-page-1#comment-9307</link>
		<dc:creator>Ian Lance Taylor</dc:creator>
		<pubDate>Thu, 10 Jan 2008 18:21:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/120#comment-9307</guid>
		<description>I think the full effects only come in on gcc mainline.  At least, gcc 4.2 does not eliminate the loop, but gcc 4.3 will.  All my examples were run with gcc mainline.</description>
		<content:encoded><![CDATA[<p>I think the full effects only come in on gcc mainline.  At least, gcc 4.2 does not eliminate the loop, but gcc 4.3 will.  All my examples were run with gcc mainline.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ncm</title>
		<link>http://www.airs.com/blog/archives/120/comment-page-1#comment-9297</link>
		<dc:creator>ncm</dc:creator>
		<pubDate>Thu, 10 Jan 2008 03:13:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/120#comment-9297</guid>
		<description>I&#039;m running 

$ gcc --version

gcc (GCC) 4.2.3 20080102 (prerelease) (Debian 4.2.2-5)

and putting all your code examples into t.c and compiling with

$ gcc -O3 -Wstrict-overflow=5 -fstrict-overflow -Wall -W -c t.c

I get no warnings at all.  Should I be surprised at this?</description>
		<content:encoded><![CDATA[<p>I&#8217;m running </p>
<p>$ gcc &#8211;version</p>
<p>gcc (GCC) 4.2.3 20080102 (prerelease) (Debian 4.2.2-5)</p>
<p>and putting all your code examples into t.c and compiling with</p>
<p>$ gcc -O3 -Wstrict-overflow=5 -fstrict-overflow -Wall -W -c t.c</p>
<p>I get no warnings at all.  Should I be surprised at this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Lance Taylor</title>
		<link>http://www.airs.com/blog/archives/120/comment-page-1#comment-9294</link>
		<dc:creator>Ian Lance Taylor</dc:creator>
		<pubDate>Thu, 10 Jan 2008 02:28:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/120#comment-9294</guid>
		<description>-Wstrict-overflow should issue a warning if you compile with -O2.  -Wstrict-overflow warns about cases where an optimization relies on undefined overflow; it doesn&#039;t have any way to detect possible overflow except when an optimization is applied.  In some cases you will need to use -Wstrict-overflow=5.

-Wall includes -Wstrict-overflow=1.  Specifying -Wstrict-overflow with no number is equivalent to -Wstrict-overflow=2.

The docs are available at http://gcc.gnu.org/onlinedocs/ .</description>
		<content:encoded><![CDATA[<p>-Wstrict-overflow should issue a warning if you compile with -O2.  -Wstrict-overflow warns about cases where an optimization relies on undefined overflow; it doesn&#8217;t have any way to detect possible overflow except when an optimization is applied.  In some cases you will need to use -Wstrict-overflow=5.</p>
<p>-Wall includes -Wstrict-overflow=1.  Specifying -Wstrict-overflow with no number is equivalent to -Wstrict-overflow=2.</p>
<p>The docs are available at <a href="http://gcc.gnu.org/onlinedocs/" rel="nofollow">http://gcc.gnu.org/onlinedocs/</a> .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ncm</title>
		<link>http://www.airs.com/blog/archives/120/comment-page-1#comment-9291</link>
		<dc:creator>ncm</dc:creator>
		<pubDate>Wed, 09 Jan 2008 22:08:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/120#comment-9291</guid>
		<description>I see that -Wstrict-overflow is accepted by Debian&#039;s gcc-4.2.3.  However, it issues no warnings for the code examples presented.

Is it included in -W or -Wall?  (Debian has not packaged gcc-4.2 docs yet.)</description>
		<content:encoded><![CDATA[<p>I see that -Wstrict-overflow is accepted by Debian&#8217;s gcc-4.2.3.  However, it issues no warnings for the code examples presented.</p>
<p>Is it included in -W or -Wall?  (Debian has not packaged gcc-4.2 docs yet.)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
