<?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"
	>
<channel>
	<title>Comments on: Fun with printf</title>
	<atom:link href="http://boredzo.org/blog/archives/2006-11-17/fun-with-printf/feed" rel="self" type="application/rss+xml" />
	<link>http://boredzo.org/blog/archives/2006-11-17/fun-with-printf</link>
	<description>The personal weblog of Peter Hosey.</description>
	<pubDate>Thu, 20 Nov 2008 16:48:51 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Kevin Ballard</title>
		<link>http://boredzo.org/blog/archives/2006-11-17/fun-with-printf#comment-4758</link>
		<dc:creator>Kevin Ballard</dc:creator>
		<pubDate>Mon, 25 Dec 2006 09:00:34 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2006-11-17/fun-with-printf#comment-4758</guid>
		<description>"random memory address"

Nothing random about it. It's printing, in octal, the integer value of the stack location above the second argument. According to the OS X ppc32 ABI (and I believe the i686 and ppc64, but I'm too lazy to check), this would correspond to the local variables area of the calling function (i.e. the function where this fprintf statement occurs). If there are no local variables, it will be in the saved registers area.

So basically, it's printing the octal representation of the integer cast of sizeof(int) of a local variable, or if none, then one of the saved registers.

I don't know what this stack location corresponds to in other ABIs, but it'll probably be something similar.

But the point here is it's definitely not random.</description>
		<content:encoded><![CDATA[<p>"random memory address"</p>
<p>Nothing random about it. It's printing, in octal, the integer value of the stack location above the second argument. According to the OS X ppc32 ABI (and I believe the i686 and ppc64, but I'm too lazy to check), this would correspond to the local variables area of the calling function (i.e. the function where this fprintf statement occurs). If there are no local variables, it will be in the saved registers area.</p>
<p>So basically, it's printing the octal representation of the integer cast of sizeof(int) of a local variable, or if none, then one of the saved registers.</p>
<p>I don't know what this stack location corresponds to in other ABIs, but it'll probably be something similar.</p>
<p>But the point here is it's definitely not random.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Hosey</title>
		<link>http://boredzo.org/blog/archives/2006-11-17/fun-with-printf#comment-870</link>
		<dc:creator>Peter Hosey</dc:creator>
		<pubDate>Fri, 17 Nov 2006 20:39:24 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2006-11-17/fun-with-printf#comment-870</guid>
		<description>Yes, that's the solution to the bug. But the point of this post was the diagnosis, not the fix. :)

Thanks, though.</description>
		<content:encoded><![CDATA[<p>Yes, that's the solution to the bug. But the point of this post was the diagnosis, not the fix. :)</p>
<p>Thanks, though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hub</title>
		<link>http://boredzo.org/blog/archives/2006-11-17/fun-with-printf#comment-869</link>
		<dc:creator>Hub</dc:creator>
		<pubDate>Fri, 17 Nov 2006 20:27:21 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2006-11-17/fun-with-printf#comment-869</guid>
		<description>Just use '%%' to escape the '%' in a format string ;-)</description>
		<content:encoded><![CDATA[<p>Just use '%%' to escape the '%' in a format string ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Hosey</title>
		<link>http://boredzo.org/blog/archives/2006-11-17/fun-with-printf#comment-868</link>
		<dc:creator>Peter Hosey</dc:creator>
		<pubDate>Fri, 17 Nov 2006 20:14:52 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2006-11-17/fun-with-printf#comment-868</guid>
		<description>Correct!</description>
		<content:encoded><![CDATA[<p>Correct!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Augie Fackler</title>
		<link>http://boredzo.org/blog/archives/2006-11-17/fun-with-printf#comment-867</link>
		<dc:creator>Augie Fackler</dc:creator>
		<pubDate>Fri, 17 Nov 2006 20:13:55 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2006-11-17/fun-with-printf#comment-867</guid>
		<description>Oh, right, I'm a retard. It's printing a random memory address as an octal value. The f just randomly threw me.</description>
		<content:encoded><![CDATA[<p>Oh, right, I'm a retard. It's printing a random memory address as an octal value. The f just randomly threw me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Hosey</title>
		<link>http://boredzo.org/blog/archives/2006-11-17/fun-with-printf#comment-866</link>
		<dc:creator>Peter Hosey</dc:creator>
		<pubDate>Fri, 17 Nov 2006 20:09:11 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2006-11-17/fun-with-printf#comment-866</guid>
		<description>Close, but not quite.</description>
		<content:encoded><![CDATA[<p>Close, but not quite.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Augie Fackler</title>
		<link>http://boredzo.org/blog/archives/2006-11-17/fun-with-printf#comment-865</link>
		<dc:creator>Augie Fackler</dc:creator>
		<pubDate>Fri, 17 Nov 2006 20:04:12 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2006-11-17/fun-with-printf#comment-865</guid>
		<description>"% of" will be interpreted as a format string for a floating point value, thus printing an arbitrary point in memory as a float.</description>
		<content:encoded><![CDATA[<p>"% of" will be interpreted as a format string for a floating point value, thus printing an arbitrary point in memory as a float.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.185 seconds -->
