<?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[Frage zu Code]]></title><description><![CDATA[<pre><code>int main()
{

        // das geht nicht
	char * string = &quot;Hallo&quot;;

	string[1] = string[1]; 

	//aber das geht

	int x = 4; 

	x= x;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/318470/frage-zu-code</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Jul 2026 16:08:20 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/318470.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 14 Jul 2013 10:23:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Frage zu Code on Sun, 14 Jul 2013 10:23:40 GMT]]></title><description><![CDATA[<pre><code>int main()
{

        // das geht nicht
	char * string = &quot;Hallo&quot;;

	string[1] = string[1]; 

	//aber das geht

	int x = 4; 

	x= x;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2338735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338735</guid><dc:creator><![CDATA[blurry333]]></dc:creator><pubDate>Sun, 14 Jul 2013 10:23:40 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Code on Sun, 14 Jul 2013 10:26:47 GMT]]></title><description><![CDATA[<p>Ist ja auch undefiniertes Verhalten...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338739</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338739</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Sun, 14 Jul 2013 10:26:47 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Code on Sun, 14 Jul 2013 10:30:06 GMT]]></title><description><![CDATA[<p>dot schrieb:</p>
<blockquote>
<p>Ist ja auch undefiniertes Verhalten...</p>
</blockquote>
<p>Echt? Für mich ist das relativ eindeutig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338740</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338740</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Sun, 14 Jul 2013 10:30:06 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Code on Sun, 14 Jul 2013 10:34:11 GMT]]></title><description><![CDATA[<p>Der Code versucht, ein const Objekt zu modifizieren...</p>
<p>Wenn <code>string</code> kein <code>char*</code> sondern ein <code>char[]</code> wäre, würds gehen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338741</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338741</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Sun, 14 Jul 2013 10:34:11 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Code on Sun, 14 Jul 2013 11:09:37 GMT]]></title><description><![CDATA[<p>Darf man eigentlich lesend über die Arraygrenzen hinweg zugreifen ? Ich leg mir ein array mit 5 Elementen und lese z.B. an Position 10 <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338751</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338751</guid><dc:creator><![CDATA[blurry333]]></dc:creator><pubDate>Sun, 14 Jul 2013 11:09:37 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Code on Sun, 14 Jul 2013 11:15:29 GMT]]></title><description><![CDATA[<p>blurry333 schrieb:</p>
<blockquote>
<p>Darf man eigentlich lesend über die Arraygrenzen hinweg zugreifen ?</p>
</blockquote>
<p>Nein, genaugenommen ist nichtmal garantiert, dass du auch nur eine Adresse, die außerhalb eines Arrays liegt, überhaupt ausrechnen kannst ohne UB. Einzige Ausnahme: Die Adresse die hinter das letzte Element zeigt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338753</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338753</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Sun, 14 Jul 2013 11:15:29 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Code on Sun, 14 Jul 2013 11:20:20 GMT]]></title><description><![CDATA[<p>dot schrieb:</p>
<blockquote>
<p>blurry333 schrieb:</p>
<blockquote>
<p>Darf man eigentlich lesend über die Arraygrenzen hinweg zugreifen ?</p>
</blockquote>
<p>Nein, genaugenommen ist nichtmal garantiert, dass du auch nur eine Adresse, die außerhalb eines Arrays liegt, überhaupt ausrechnen kannst ohne UB. Einzige Ausnahme: Die Adresse die hinter das letzte Element zeigt.</p>
</blockquote>
<p>Meinst du solche Fälle wie die Adresse 4294967295 (auf 32Bit Systemen)?<br />
Da wäre die nächste Adresse ja die 0...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338758</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338758</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Sun, 14 Jul 2013 11:20:20 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Code on Sun, 14 Jul 2013 11:22:41 GMT]]></title><description><![CDATA[<p>C++ Standard schrieb:</p>
<blockquote>
<p>If both the pointer operand and the result point to elements of the same array object, or one past the last element of the array object, the evaluation shall not produce an overflow; otherwise, the behavior is undefined.</p>
</blockquote>
<p>Aber ja, genau das wäre z.B. so ein Fall...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338759</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338759</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Sun, 14 Jul 2013 11:22:41 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Code on Sun, 14 Jul 2013 11:42:09 GMT]]></title><description><![CDATA[<p>dot schrieb:</p>
<blockquote>
<p>Der Code versucht, ein const Objekt zu modifizieren...</p>
<p>Wenn <code>string</code> kein <code>char*</code> sondern ein <code>char[]</code> wäre, würds gehen...</p>
</blockquote>
<p>Ja, das erste Codefragment, habe nur auf das Zweite geschaut, my bad.</p>
<p>Skym0sh0 schrieb:</p>
<blockquote>
<p>dot schrieb:</p>
<blockquote>
<p>blurry333 schrieb:</p>
<blockquote>
<p>Darf man eigentlich lesend über die Arraygrenzen hinweg zugreifen ?</p>
</blockquote>
<p>Nein, genaugenommen ist nichtmal garantiert, dass du auch nur eine Adresse, die außerhalb eines Arrays liegt, überhaupt ausrechnen kannst ohne UB. Einzige Ausnahme: Die Adresse die hinter das letzte Element zeigt.</p>
</blockquote>
<p>Meinst du solche Fälle wie die Adresse 4294967295 (auf 32Bit Systemen)?<br />
Da wäre die nächste Adresse ja die 0...</p>
</blockquote>
<p>Vlt eher soetwas:</p>
<pre><code>int a; 
int b;
auto diff = &amp;b - &amp;a;
int* pb = &amp;a + diff;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2338767</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338767</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Sun, 14 Jul 2013 11:42:09 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Code on Sun, 14 Jul 2013 11:46:36 GMT]]></title><description><![CDATA[<p>Ethon schrieb:</p>
<blockquote>
<p>Vlt eher soetwas:</p>
<pre><code>int a; 
int b;
auto diff = &amp;b - &amp;a;
int* pb = &amp;a + diff;
</code></pre>
</blockquote>
<p>Ja, das ist auch bereits UB, auch wenn es in der Praxis wohl in der Regel funktionieren wird...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338768</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338768</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Sun, 14 Jul 2013 11:46:36 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Code on Sun, 14 Jul 2013 11:50:43 GMT]]></title><description><![CDATA[<p>Ethon schrieb:</p>
<blockquote>
<p>Vlt eher soetwas:</p>
<pre><code>int a; 
int b;
auto diff = &amp;b - &amp;a;   // &lt;- undefiniertes Verhalten
int* pb = &amp;a + diff;
</code></pre>
</blockquote>
<p>Gemeint ist sowas:</p>
<pre><code class="language-cpp">int a[10];
int *p = &amp;a[10]; // OK, obwohl Index 10 außerhalb von a liegt
// p = &amp;a[11]; // nicht OK
</code></pre>
<p>BTW hätte nicht gedacht, dass so eine einfache Bemerkung auf soviele ratlose Gesichter stößt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338770</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338770</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Sun, 14 Jul 2013 11:50:43 GMT</pubDate></item></channel></rss>