<?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: Can references be null?</title>
	<atom:link href="http://www.nicollet.net/2009/11/can-references-be-null/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nicollet.net/2009/11/can-references-be-null/</link>
	<description>Go crazy with computers</description>
	<lastBuildDate>Thu, 04 Mar 2010 21:41:36 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Emmanuel Deloget</title>
		<link>http://www.nicollet.net/2009/11/can-references-be-null/comment-page-1/#comment-14493</link>
		<dc:creator>Emmanuel Deloget</dc:creator>
		<pubDate>Sun, 15 Nov 2009 23:52:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.nicollet.net/?p=1185#comment-14493</guid>
		<description>The seasonned programmer is, I hope, knowledgeable enough to understand how to avoid the trap of dereferencing a null/invalid pointer. An invalid reference can be created in two ways : 

1) dereferencing a pointer
2) using a reference to a variable that went out of scope

The compiler is supposed to warn you about most occurences of (2) (typical case: when your function returns a reference to an automatic local variable)

(1) is not supposed to be done at all. I understand that in very rare cases, a programmer might believe that he have to dereference a pointer to initialize a reference, but this is a bad thing and it should be avoided at all cost - mostly because code like this is way too dangerous to end in production code.</description>
		<content:encoded><![CDATA[<p>The seasonned programmer is, I hope, knowledgeable enough to understand how to avoid the trap of dereferencing a null/invalid pointer. An invalid reference can be created in two ways : </p>
<p>1) dereferencing a pointer<br />
2) using a reference to a variable that went out of scope</p>
<p>The compiler is supposed to warn you about most occurences of (2) (typical case: when your function returns a reference to an automatic local variable)</p>
<p>(1) is not supposed to be done at all. I understand that in very rare cases, a programmer might believe that he have to dereference a pointer to initialize a reference, but this is a bad thing and it should be avoided at all cost &#8211; mostly because code like this is way too dangerous to end in production code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Victor Nicollet</title>
		<link>http://www.nicollet.net/2009/11/can-references-be-null/comment-page-1/#comment-14109</link>
		<dc:creator>Victor Nicollet</dc:creator>
		<pubDate>Wed, 04 Nov 2009 00:34:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.nicollet.net/?p=1185#comment-14109</guid>
		<description>I certainly would not advocate judging someone on a single statement in an actual interview ;)</description>
		<content:encoded><![CDATA[<p>I certainly would not advocate judging someone on a single statement in an actual interview <img src='http://www.nicollet.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rip-off</title>
		<link>http://www.nicollet.net/2009/11/can-references-be-null/comment-page-1/#comment-14107</link>
		<dc:creator>rip-off</dc:creator>
		<pubDate>Tue, 03 Nov 2009 23:27:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.nicollet.net/?p=1185#comment-14107</guid>
		<description>I like writing standard code, and I would promote the standard argument that references cannot be null in legal code.

However, for a development position, you generally won&#039;t be dealing with 100% legal C++ code. Very few non-trivial C++ programs manage to avoid skirting through some hairy section of the standard. Even the programmer with the best intentions of following the standard can write code with bugs that cause &quot;null references&quot; to appear.

I think C++ programmers should be aware of both the theory that references cannot be null, but that in practise you might encounter a null reference.

So, what does the “C++ references can be null” statement tell me about someone ?

Either they are like you have described, or possibly that they are seasoned programmers who know that the &quot;impossible&quot; case is all too likely to arise, and that standards tend to be aimed at rather than achieved. Further probing is necessary to distinguish such programmers, rather than writing them off.

IMHO =)</description>
		<content:encoded><![CDATA[<p>I like writing standard code, and I would promote the standard argument that references cannot be null in legal code.</p>
<p>However, for a development position, you generally won&#8217;t be dealing with 100% legal C++ code. Very few non-trivial C++ programs manage to avoid skirting through some hairy section of the standard. Even the programmer with the best intentions of following the standard can write code with bugs that cause &#8220;null references&#8221; to appear.</p>
<p>I think C++ programmers should be aware of both the theory that references cannot be null, but that in practise you might encounter a null reference.</p>
<p>So, what does the “C++ references can be null” statement tell me about someone ?</p>
<p>Either they are like you have described, or possibly that they are seasoned programmers who know that the &#8220;impossible&#8221; case is all too likely to arise, and that standards tend to be aimed at rather than achieved. Further probing is necessary to distinguish such programmers, rather than writing them off.</p>
<p>IMHO =)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Liam</title>
		<link>http://www.nicollet.net/2009/11/can-references-be-null/comment-page-1/#comment-14093</link>
		<dc:creator>Liam</dc:creator>
		<pubDate>Tue, 03 Nov 2009 13:26:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.nicollet.net/?p=1185#comment-14093</guid>
		<description>LOL -pointer +reference. That is what your arsey pedantic comment did to me.</description>
		<content:encoded><![CDATA[<p>LOL -pointer +reference. That is what your arsey pedantic comment did to me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Liam</title>
		<link>http://www.nicollet.net/2009/11/can-references-be-null/comment-page-1/#comment-14092</link>
		<dc:creator>Liam</dc:creator>
		<pubDate>Tue, 03 Nov 2009 13:25:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.nicollet.net/?p=1185#comment-14092</guid>
		<description>Ok if you are going to be pedantic when clearly this article is about C++. Using the term null pointer when talking about C++ references makes no sense.</description>
		<content:encoded><![CDATA[<p>Ok if you are going to be pedantic when clearly this article is about C++. Using the term null pointer when talking about C++ references makes no sense.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Victor Nicollet</title>
		<link>http://www.nicollet.net/2009/11/can-references-be-null/comment-page-1/#comment-14091</link>
		<dc:creator>Victor Nicollet</dc:creator>
		<pubDate>Tue, 03 Nov 2009 13:13:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.nicollet.net/?p=1185#comment-14091</guid>
		<description>Using the term null when talking about references does make sense (see C#/Java), but the feature is unsupported by C++ and is not defined by the standard. Just like the world &quot;closure&quot; doesn&#039;t stop making sense once you enter the world of C++ :)</description>
		<content:encoded><![CDATA[<p>Using the term null when talking about references does make sense (see C#/Java), but the feature is unsupported by C++ and is not defined by the standard. Just like the world &#8220;closure&#8221; doesn&#8217;t stop making sense once you enter the world of C++ <img src='http://www.nicollet.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Liam</title>
		<link>http://www.nicollet.net/2009/11/can-references-be-null/comment-page-1/#comment-14088</link>
		<dc:creator>Liam</dc:creator>
		<pubDate>Tue, 03 Nov 2009 11:43:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.nicollet.net/?p=1185#comment-14088</guid>
		<description>Whilst I agree with you, if someone was to show me the example code and asked the question I would correct them using some of the explaination you have used.

The example code is invalid for one reason and one reason only and that is because it dereffences a null pointer. 

Using the term null when talking about references does not make any sense and I would question who or which group of people use the &quot;commonly accepted definition&quot;?
I would point out to them that a reference can become invalid but this is undefined behaviour by the very nature of references in C++.</description>
		<content:encoded><![CDATA[<p>Whilst I agree with you, if someone was to show me the example code and asked the question I would correct them using some of the explaination you have used.</p>
<p>The example code is invalid for one reason and one reason only and that is because it dereffences a null pointer. </p>
<p>Using the term null when talking about references does not make any sense and I would question who or which group of people use the &#8220;commonly accepted definition&#8221;?<br />
I would point out to them that a reference can become invalid but this is undefined behaviour by the very nature of references in C++.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
