<?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[[GELÖST] Merkwürdige Ausgabe bei const std::vector]]></title><description><![CDATA[<p>Abend,<br />
ich bekomme eine merkwürdige Ausgabe, wenn ich auf ein Vektorelement zugreife, egal ob ich [] oder at() verwende.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;vector&gt;

int main()
{
	const std::vector&lt;int&gt; vec(10);
	vec[0]; // Hier bekomme ich eine Ausgabe: aasakjasklajaasakl

    std::cin.get();
}
</code></pre>
<p>Lasse ich <code>const</code> weg, kommt die Ausgabe nicht mehr. Kann das jemand erklären?</p>
<p>Danke im Voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/299598/gelöst-merkwürdige-ausgabe-bei-const-std-vector</link><generator>RSS for Node</generator><lastBuildDate>Thu, 13 Aug 2026 03:19:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/299598.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 14 Feb 2012 18:16:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Tue, 14 Feb 2012 18:36:13 GMT]]></title><description><![CDATA[<p>Abend,<br />
ich bekomme eine merkwürdige Ausgabe, wenn ich auf ein Vektorelement zugreife, egal ob ich [] oder at() verwende.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;vector&gt;

int main()
{
	const std::vector&lt;int&gt; vec(10);
	vec[0]; // Hier bekomme ich eine Ausgabe: aasakjasklajaasakl

    std::cin.get();
}
</code></pre>
<p>Lasse ich <code>const</code> weg, kommt die Ausgabe nicht mehr. Kann das jemand erklären?</p>
<p>Danke im Voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181146</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181146</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 14 Feb 2012 18:36:13 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Tue, 14 Feb 2012 18:35:45 GMT]]></title><description><![CDATA[<p>Ich hab mir mal die Header auf dem PC suchen lasse:</p>
<pre><code class="language-cpp">const_reference
      operator[](size_type __n) const
      {
			std::cout &lt;&lt; &quot;aasakjasklajssaskl&quot;;
			return *(this-&gt;_M_impl._M_start + __n); }

    protected:
      /// Safety check used only from at().
      void
      _M_range_check(size_type __n) const
      {
	if (__n &gt;= this-&gt;size())
	  __throw_out_of_range(__N(&quot;vector::_M_range_check&quot;));
      }
</code></pre>
<p>Was auch immer im Kopf dieses Entwicklers vorging.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181152</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181152</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 14 Feb 2012 18:35:45 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Tue, 14 Feb 2012 18:42:07 GMT]]></title><description><![CDATA[<p>Wo hast du den Compiler her? Bei mir sieht es so aus:</p>
<pre><code class="language-cpp">/**
       *  @brief  Subscript access to the data contained in the %vector.
       *  @param __n The index of the element for which data should be
       *  accessed.
       *  @return  Read-only (constant) reference to data.
       *
       *  This operator allows for easy, array-style, data access.
       *  Note that data access with this operator is unchecked and
       *  out_of_range lookups are not defined. (For checked lookups
       *  see at().)
       */
      const_reference
      operator[](size_type __n) const
      { return *(this-&gt;_M_impl._M_start + __n); }
</code></pre>
<p>GCC 4.7, welchen Compiler hast du?</p>
<p>Edit: Also ich hab praktisch genau denselben Code wie du, nur halt ohne diese Ausgabe. Einfach wegmachen, vergessen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181155</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181155</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 14 Feb 2012 18:42:07 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Tue, 14 Feb 2012 18:42:25 GMT]]></title><description><![CDATA[<p>Hacker schrieb:</p>
<blockquote>
<p>welchen Compiler hast du?</p>
</blockquote>
<p>MinGW GCC 4.6.1 32-bit</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181156</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181156</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 14 Feb 2012 18:42:25 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Tue, 14 Feb 2012 18:46:49 GMT]]></title><description><![CDATA[<p>WTF? Willst du uns veräppeln?<br />
Sicher, dass da niemand sonst was an dem Code geändert hat?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181160</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181160</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Tue, 14 Feb 2012 18:46:49 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Tue, 14 Feb 2012 18:50:40 GMT]]></title><description><![CDATA[<p>drakon schrieb:</p>
<blockquote>
<p>WTF? Willst du uns veräppeln?<br />
Sicher, dass da niemand sonst was an dem Code geändert hat?</p>
</blockquote>
<p>(-_-)</p>
<p>Das ist doch mal sowas von klar, dass das nur ein hobbyloser Vollidiot gewesen sein kann, dazu noch ein ganz unlustiger.</p>
<p>Wo hast du denn den Compiler gedownloadet?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181162</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181162</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 14 Feb 2012 18:50:40 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Tue, 14 Feb 2012 18:51:52 GMT]]></title><description><![CDATA[<p>drakon schrieb:</p>
<blockquote>
<p>WTF? Willst du uns veräppeln?<br />
Sicher, dass da niemand sonst was an dem Code geändert hat?</p>
</blockquote>
<p>Nein, es steht so in <code>stl_vector.h</code> geschrieben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181165</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181165</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 14 Feb 2012 18:51:52 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Tue, 14 Feb 2012 18:56:46 GMT]]></title><description><![CDATA[<p>Hacker schrieb:</p>
<blockquote>
<p>Wo hast du denn den Compiler gedownloadet?</p>
</blockquote>
<p>Ich bin gerade am PC meiner Eltern, und da ist ein neueres <a href="http://sourceforge.net/projects/orwelldevcpp/files/Setup%20Releases/devcpp-5.0.0.9_setup.exe/download" rel="nofollow">Dev-C++</a> installiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181168</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181168</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 14 Feb 2012 18:56:46 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Tue, 14 Feb 2012 19:04:52 GMT]]></title><description><![CDATA[<p>Gugelmoser schrieb:</p>
<blockquote>
<p>drakon schrieb:</p>
<blockquote>
<p>WTF? Willst du uns veräppeln?<br />
Sicher, dass da niemand sonst was an dem Code geändert hat?</p>
</blockquote>
<p>Nein, es steht so in <code>stl_vector.h</code> geschrieben.</p>
</blockquote>
<p>Je nach OS kann da jeder, oder zumindest ein Admin, verändern was er möchte. Bei Elternsystemen erfahrungsgemäß eher jeder, weil jeder Admin ist <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>
<p>P.S.: Von der Art der Veränderung her jemand der dachte, er würde sich auf diese Weise einen schwer zu entdeckenden Scherz erlauben, dabei aber nicht sonderlich kreativ war. Bei TDWTF gab es glaube ich mal einen Wettbewerb, welche Art von unauffälligem &quot;Geschenk&quot; man im Code eines unliebsamen Arbeitgebers zum Abschied hinterlassen könnte. Da kamen weitaus fiesere und gleichzeitig schwerer zu entdeckende Sachen bei rum.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181173</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181173</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 14 Feb 2012 19:04:52 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Tue, 14 Feb 2012 19:22:46 GMT]]></title><description><![CDATA[<p>Ich habs gerade deinstalliert und danach neu installiert. Und tatsächlich, nun sieht das Ganze so aus:</p>
<pre><code class="language-cpp">/**
       *  @brief  Subscript access to the data contained in the %vector.
       *  @param n The index of the element for which data should be
       *  accessed.
       *  @return  Read-only (constant) reference to data.
       *
       *  This operator allows for easy, array-style, data access.
       *  Note that data access with this operator is unchecked and
       *  out_of_range lookups are not defined. (For checked lookups
       *  see at().)
       */
      const_reference
      operator[](size_type __n) const
      { return *(this-&gt;_M_impl._M_start + __n); }
</code></pre>
<p>Nun bin ich noch mehr verwirrt als zu Beginn. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181187</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181187</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 14 Feb 2012 19:22:46 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Tue, 14 Feb 2012 19:23:38 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Gugelmoser schrieb:</p>
<blockquote>
<p>drakon schrieb:</p>
<blockquote>
<p>WTF? Willst du uns veräppeln?<br />
Sicher, dass da niemand sonst was an dem Code geändert hat?</p>
</blockquote>
<p>Nein, es steht so in <code>stl_vector.h</code> geschrieben.</p>
</blockquote>
<p>Je nach OS kann da jeder, oder zumindest ein Admin, verändern was er möchte. Bei Elternsystemen erfahrungsgemäß eher jeder, weil jeder Admin ist <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>
</blockquote>
<p>Ich habe jetzt eher an merkwürdige Source gedacht, aber das ist sicher auch möglich.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181189</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181189</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Tue, 14 Feb 2012 19:23:38 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Tue, 14 Feb 2012 19:44:17 GMT]]></title><description><![CDATA[<p>Wie ein Scherz sieht das IMHO nicht aus, eher wie ne (völlig schlechte) Debugausgabe. Als Scherz wäre eher sowas wie &quot;Are you sure you want to delete C:? [y|n]&quot; geeignet <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181200</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181200</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Tue, 14 Feb 2012 19:44:17 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Tue, 14 Feb 2012 20:51:45 GMT]]></title><description><![CDATA[<p>Mir kam grad ein Gedankenblitz - du bist doch nicht Michael Ende? XD</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181234</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181234</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 14 Feb 2012 20:51:45 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Thu, 16 Feb 2012 12:19:26 GMT]]></title><description><![CDATA[<p>Ich habe soetwas mal aus versehen mit boost selbst produziert. Ich habe irgendetwas debuggt, wobei ich auch durch boost-Quellen durchgestept bin. Dann wollte ich per Copy&amp;Paste eine Code zur Ausgabe von einer Quelle in einer andere kopieren, und irgenddwie ist das in einer der durchs Debuggen geöffneten boost-Quellen gelandet. War aber nichts der schlimmste Fauxpas dieser Art war:<br />
Das Schlimmste war, als ich nach dem Debuggen in einem Standardheader ein ; (zwei Fenster, falscher Fokus, Backspace gedrückt und nicht aufgepasst) gelöscht hatte. Eine Flut von Fehlermeldungen, welche so gar nicht auf das Problem hingewiesen haben, war ganz toll. Seit dem setze ich alle Libs auf Read-Only...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181893</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181893</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Thu, 16 Feb 2012 12:19:26 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Thu, 16 Feb 2012 20:59:37 GMT]]></title><description><![CDATA[<p>Tachyon schrieb:</p>
<blockquote>
<p>Seit dem setze ich alle Libs auf Read-Only...</p>
</blockquote>
<p>Visual Studio macht das beim Installieren netterweise selbst <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="🙂"
    /><br />
(EDIT: doch nicht, siehe unten /EDIT)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2181989</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2181989</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 16 Feb 2012 20:59:37 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Thu, 16 Feb 2012 18:14:50 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>Tachyon schrieb:</p>
<blockquote>
<p>Seit dem setze ich alle Libs auf Read-Only...</p>
</blockquote>
<p>Visual Studio macht das beim Installieren netterweise selbst <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>
</blockquote>
<p>Die 2008er Version mit Sicherheit nicht...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2182016</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2182016</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Thu, 16 Feb 2012 18:14:50 GMT</pubDate></item><item><title><![CDATA[Reply to [GELÖST] Merkwürdige Ausgabe bei const std::vector on Thu, 16 Feb 2012 20:59:09 GMT]]></title><description><![CDATA[<p>Tachyon schrieb:</p>
<blockquote>
<p>hustbaer schrieb:</p>
<blockquote>
<p>Tachyon schrieb:</p>
<blockquote>
<p>Seit dem setze ich alle Libs auf Read-Only...</p>
</blockquote>
<p>Visual Studio macht das beim Installieren netterweise selbst <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>
</blockquote>
<p>Die 2008er Version mit Sicherheit nicht...</p>
</blockquote>
<p>Oh wie feig, das gilt anscheinend nur für die Source-Files, aber nicht für die Header-Files (weder CRT noch STL).<br />
So ein Dreck so ein elendiger!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2182082</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2182082</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 16 Feb 2012 20:59:09 GMT</pubDate></item></channel></rss>