<?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: The peril of index(3)</title>
	<atom:link href="http://boredzo.org/blog/archives/2009-11-05/the-peril-of-the-index-function/feed" rel="self" type="application/rss+xml" />
	<link>http://boredzo.org/blog/archives/2009-11-05/the-peril-of-the-index-function</link>
	<description>The personal weblog of Peter Hosey.</description>
	<lastBuildDate>Wed, 09 May 2012 18:26:35 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	<item>
		<title>By: Jonathan Mitchell</title>
		<link>http://boredzo.org/blog/archives/2009-11-05/the-peril-of-the-index-function/comment-page-1#comment-296839</link>
		<dc:creator>Jonathan Mitchell</dc:creator>
		<pubDate>Tue, 08 Dec 2009 23:14:15 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1135#comment-296839</guid>
		<description>GCC 4.2 as shipped with Xcode 3.2.1 does shadow your local variables as well as parameters and globals.

Warn whenever a local variable shadows another local variable, parameter or global variable or whenever a built-in function is shadowed.  [GCC_WARN_SHADOW, -Wshadow]</description>
		<content:encoded><![CDATA[<p>GCC 4.2 as shipped with Xcode 3.2.1 does shadow your local variables as well as parameters and globals.</p>
<p>Warn whenever a local variable shadows another local variable, parameter or global variable or whenever a built-in function is shadowed.  [GCC_WARN_SHADOW, -Wshadow]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens Alfke</title>
		<link>http://boredzo.org/blog/archives/2009-11-05/the-peril-of-the-index-function/comment-page-1#comment-294880</link>
		<dc:creator>Jens Alfke</dc:creator>
		<pubDate>Fri, 13 Nov 2009 23:17:32 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1135#comment-294880</guid>
		<description>I disagree. If you can pass a pointer as an array index and not get a compile error, something&#039;s dangerously wrong with your build process. This is why I ALWAYS, ALWAYS build with -Werror (&quot;Treat warnings as errors&quot;.) There are too many things GCC treats as warnings that are very dangerous and should be fixed immediately. This goes double for Obj-C programming, where things like misspelled selectors only generate warnings.

I find the shadowing warning useless because it yells about all sorts of names that happen to be used by C and POSIX APIs — not just index but time and a bunch of others. I&#039;d like to have a warning that told me when I was shadowing my own local variables, but I don&#039;t think GCC has that.</description>
		<content:encoded><![CDATA[<p>I disagree. If you can pass a pointer as an array index and not get a compile error, something&#8217;s dangerously wrong with your build process. This is why I ALWAYS, ALWAYS build with -Werror (&#8220;Treat warnings as errors&#8221;.) There are too many things GCC treats as warnings that are very dangerous and should be fixed immediately. This goes double for Obj-C programming, where things like misspelled selectors only generate warnings.</p>
<p>I find the shadowing warning useless because it yells about all sorts of names that happen to be used by C and POSIX APIs — not just index but time and a bunch of others. I&#8217;d like to have a warning that told me when I was shadowing my own local variables, but I don&#8217;t think GCC has that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Hosey</title>
		<link>http://boredzo.org/blog/archives/2009-11-05/the-peril-of-the-index-function/comment-page-1#comment-294278</link>
		<dc:creator>Peter Hosey</dc:creator>
		<pubDate>Fri, 06 Nov 2009 04:52:31 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1135#comment-294278</guid>
		<description>I haven&#039;t had the compiler throw an error about it once, except when I build with “Treat Warnings as Errors” turned on (which is good for many reasons, including this one). But I have encountered the crash. Less time spent fixing oops-my-variable-declaration-went-missing bugs is more time spent fixing real bugs and adding features.

And &lt;code&gt;idx&lt;/code&gt; really isn&#039;t &lt;em&gt;that&lt;/em&gt; unreadable, although I do try to consider whether &lt;code&gt;fooIndex&lt;/code&gt; or &lt;code&gt;indexOfFoo&lt;/code&gt; might be better without being obnoxiously long. The main thing is to not use &lt;code&gt;index&lt;code&gt;.</description>
		<content:encoded><![CDATA[<p>I haven&#8217;t had the compiler throw an error about it once, except when I build with “Treat Warnings as Errors” turned on (which is good for many reasons, including this one). But I have encountered the crash. Less time spent fixing oops-my-variable-declaration-went-missing bugs is more time spent fixing real bugs and adding features.</p>
<p>And <code>idx</code> really isn&#8217;t <em>that</em> unreadable, although I do try to consider whether <code>fooIndex</code> or <code>indexOfFoo</code> might be better without being obnoxiously long. The main thing is to not use <code>index</code><code>.</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy Finnell</title>
		<link>http://boredzo.org/blog/archives/2009-11-05/the-peril-of-the-index-function/comment-page-1#comment-294277</link>
		<dc:creator>Andy Finnell</dc:creator>
		<pubDate>Fri, 06 Nov 2009 04:48:20 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1135#comment-294277</guid>
		<description>I see what your saying, but if you remove your declaration of index (accidental or otherwise) you get all sorts of warnings about trying to use a pointer as an integer (at least I did when I tried it). Depending on what you try to do with index (such as math) the compiler will even throw errors. I can appreciate that you&#039;ve  been bitten by this before, but this seems really edge case. I prefer to have readable names, and trust the compiler will catch my mistakes.</description>
		<content:encoded><![CDATA[<p>I see what your saying, but if you remove your declaration of index (accidental or otherwise) you get all sorts of warnings about trying to use a pointer as an integer (at least I did when I tried it). Depending on what you try to do with index (such as math) the compiler will even throw errors. I can appreciate that you&#8217;ve  been bitten by this before, but this seems really edge case. I prefer to have readable names, and trust the compiler will catch my mistakes.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

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

