<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Ist nullptr ein erlaubter Wert für einen InputIterator?]]></title><description><![CDATA[<p>Darf man das oder hat das undefiniertes Verhalten?</p>
<pre><code class="language-cpp">char *i = nullptr;
std::copy_n(i, 0, does_not_matter);
</code></pre>
<p>GCC 4.8 hat kein Problem damit. VC++ 2013 schmeißt ein Debug Assertion Failed.<br />
Anscheinend wird der <code>nullptr</code> als ungültig befunden bevor die Länge geprüft wird:</p>
<pre><code class="language-cpp">template&lt;class _InIt,
	class _Diff,
	class _OutIt&gt; inline
	_OutIt copy_n(_InIt _First, _Diff _Count,
		_OutIt _Dest)
	{	// copy [_First, _First + _Count) to [_Dest, ...)
	_DEBUG_POINTER(_First);
	_DEBUG_POINTER(_Dest);
	if (_Count &lt;= 0)
		return (_Dest);
	else
		return (_Copy_n(_First, _Count,
			_Dest, _Is_checked(_Dest)));
	}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/327304/ist-nullptr-ein-erlaubter-wert-für-einen-inputiterator</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Jul 2026 12:06:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/327304.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 03 Aug 2014 11:47:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ist nullptr ein erlaubter Wert für einen InputIterator? on Sun, 03 Aug 2014 12:08:18 GMT]]></title><description><![CDATA[<p>Darf man das oder hat das undefiniertes Verhalten?</p>
<pre><code class="language-cpp">char *i = nullptr;
std::copy_n(i, 0, does_not_matter);
</code></pre>
<p>GCC 4.8 hat kein Problem damit. VC++ 2013 schmeißt ein Debug Assertion Failed.<br />
Anscheinend wird der <code>nullptr</code> als ungültig befunden bevor die Länge geprüft wird:</p>
<pre><code class="language-cpp">template&lt;class _InIt,
	class _Diff,
	class _OutIt&gt; inline
	_OutIt copy_n(_InIt _First, _Diff _Count,
		_OutIt _Dest)
	{	// copy [_First, _First + _Count) to [_Dest, ...)
	_DEBUG_POINTER(_First);
	_DEBUG_POINTER(_Dest);
	if (_Count &lt;= 0)
		return (_Dest);
	else
		return (_Copy_n(_First, _Count,
			_Dest, _Is_checked(_Dest)));
	}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2411724</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2411724</guid><dc:creator><![CDATA[TyRoXx]]></dc:creator><pubDate>Sun, 03 Aug 2014 12:08:18 GMT</pubDate></item><item><title><![CDATA[Reply to Ist nullptr ein erlaubter Wert für einen InputIterator? on Sun, 03 Aug 2014 12:01:28 GMT]]></title><description><![CDATA[<p>nullptr ist ein gültiger End-Iterator.</p>
<p>Daniel Krügler &lt;a href= schrieb:</p>
<blockquote>
<p><a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53248#c6" rel="nofollow">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53248#c6</a>&quot;&gt;</p>
<blockquote>
<p>&gt; By the way - I think we discussed this already, bu now I can't find anything -<br />
&gt; what should we take the begin() == end() == unique value exactly to mean? Don't<br />
&gt; tell me something like an ugly reinterpret_cast&lt;T*&gt;(this), please</p>
</blockquote>
<p>My interpretation is that returning nullptr should be OK. I don't see any requirement that a unique value is something that cannot be returned by any other container (In a private communication with Howard he at least agreed with my interpretation). If this interpretation is unsafe, it should also be clarified by revised wording.</p>
</blockquote>
<p>(Ist jetzt zwar kein Zitat aus dem Standard, aber wenn Daniel Krügler und Howard Hinnant der gleichen Meinung sind, dürfte man das als ziemlich bindend betrachten.)</p>
<p>InputIterator dürfen auch im past-the-end Zustand sein, also ist das mMn ein Bug in VS.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2411725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2411725</guid><dc:creator><![CDATA[visualscheisse]]></dc:creator><pubDate>Sun, 03 Aug 2014 12:01:28 GMT</pubDate></item></channel></rss>