<?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[Weird behavior of range-based for]]></title><description><![CDATA[<pre><code>#include &lt;iostream&gt;

struct My {
    int x;
    My(void): x(42) { std::cout &lt;&lt; &quot;Constructed: &quot; &lt;&lt; this &lt;&lt; std::endl; }
    My(My const &amp;m): x(m.x) { std::cout &lt;&lt; &quot;Copy constructed: &quot; &lt;&lt; this &lt;&lt; std::endl; }
    ~My(void) { x = 0; std::cout &lt;&lt; &quot;Destructed: &quot; &lt;&lt; this &lt;&lt; std::endl; }
};

int main(void) {
  for(My const &amp;i: {My(), My(), My()}) {
      std::cout &lt;&lt; i.x &lt;&lt; std::endl;
  }
  return 0;
}
</code></pre>
<p>g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3:</p>
<pre><code>Constructed: 0x7fff006f0510
Constructed: 0x7fff006f0514
Constructed: 0x7fff006f0518
Destructed: 0x7fff006f0518
Destructed: 0x7fff006f0514
Destructed: 0x7fff006f0510
0
0
0
</code></pre>
<p>Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn):</p>
<pre><code>Constructed: 0x7fff5fbff7e0
Constructed: 0x7fff5fbff7e4
Constructed: 0x7fff5fbff7e8
42
42
42
</code></pre>
<p>Ideone (<a href="http://ideone.com/uz6SUG" rel="nofollow">http://ideone.com/uz6SUG</a>)</p>
<pre><code>Constructed: 0xbfdf13d4
Constructed: 0xbfdf13d8
Constructed: 0xbfdf13dc
42
42
42
Destructed: 0xbfdf13dc
Destructed: 0xbfdf13d8
Destructed: 0xbfdf13d4
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/315673/weird-behavior-of-range-based-for</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Jul 2026 08:22:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/315673.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 09 Apr 2013 06:40:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Weird behavior of range-based for on Tue, 09 Apr 2013 06:41:10 GMT]]></title><description><![CDATA[<pre><code>#include &lt;iostream&gt;

struct My {
    int x;
    My(void): x(42) { std::cout &lt;&lt; &quot;Constructed: &quot; &lt;&lt; this &lt;&lt; std::endl; }
    My(My const &amp;m): x(m.x) { std::cout &lt;&lt; &quot;Copy constructed: &quot; &lt;&lt; this &lt;&lt; std::endl; }
    ~My(void) { x = 0; std::cout &lt;&lt; &quot;Destructed: &quot; &lt;&lt; this &lt;&lt; std::endl; }
};

int main(void) {
  for(My const &amp;i: {My(), My(), My()}) {
      std::cout &lt;&lt; i.x &lt;&lt; std::endl;
  }
  return 0;
}
</code></pre>
<p>g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3:</p>
<pre><code>Constructed: 0x7fff006f0510
Constructed: 0x7fff006f0514
Constructed: 0x7fff006f0518
Destructed: 0x7fff006f0518
Destructed: 0x7fff006f0514
Destructed: 0x7fff006f0510
0
0
0
</code></pre>
<p>Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn):</p>
<pre><code>Constructed: 0x7fff5fbff7e0
Constructed: 0x7fff5fbff7e4
Constructed: 0x7fff5fbff7e8
42
42
42
</code></pre>
<p>Ideone (<a href="http://ideone.com/uz6SUG" rel="nofollow">http://ideone.com/uz6SUG</a>)</p>
<pre><code>Constructed: 0xbfdf13d4
Constructed: 0xbfdf13d8
Constructed: 0xbfdf13dc
42
42
42
Destructed: 0xbfdf13dc
Destructed: 0xbfdf13d8
Destructed: 0xbfdf13d4
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2313918</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2313918</guid><dc:creator><![CDATA[SAn]]></dc:creator><pubDate>Tue, 09 Apr 2013 06:41:10 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Tue, 09 Apr 2013 07:14:55 GMT]]></title><description><![CDATA[<p>I think these compilers have a problem with lifetime prolongation for r-values.</p>
<p>If you change your code this (which is mostly equivalent), you will see the problem:</p>
<pre><code>std::initializer_list&lt;My&gt;&amp;&amp; inili = {My{}, My{}, My{}};
std::cout &lt;&lt; &quot;starting for loop&quot; &lt;&lt; std::endl;
for(My const &amp;i: inili) {
    std::cout &lt;&lt; i.x &lt;&lt; std::endl;
}
</code></pre>
<p>I'm not surprised that GCC 4.6.3 fails (he is pretty ancient), but it doesn't work with Clang 3.2 (real version). There surely exists a bug on that.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2313929</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2313929</guid><dc:creator><![CDATA[hoplite]]></dc:creator><pubDate>Tue, 09 Apr 2013 07:14:55 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Mon, 22 Apr 2013 07:10:01 GMT]]></title><description><![CDATA[<p>So, what should I do?<br />
We here use GCC 4.6.3.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317356</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317356</guid><dc:creator><![CDATA[SAn]]></dc:creator><pubDate>Mon, 22 Apr 2013 07:10:01 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Mon, 22 Apr 2013 09:08:13 GMT]]></title><description><![CDATA[<p>SAn schrieb:</p>
<blockquote>
<p>So, what should I do?<br />
We here use GCC 4.6.3.</p>
</blockquote>
<p>Don't use <s>rvalue-ranges</s> initializer-lists directly.</p>
<p>i.e.</p>
<pre><code class="language-cpp">auto range = {My{}, My{}, My{}};
std::cout &lt;&lt; &quot;starting for loop&quot; &lt;&lt; std::endl;
for(My const &amp;i: range) {
    std::cout &lt;&lt; i.x &lt;&lt; std::endl;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2317371</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317371</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 22 Apr 2013 09:08:13 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Mon, 22 Apr 2013 10:46:12 GMT]]></title><description><![CDATA[<p>Interesting. To be honest, it does not surprize me that different compiler (versions) handle this differently. I'm not sure whether I fully grasp the magic of initialiter_list with respect to life-time by now or not. On one hand a good compiler is supposed to be smart enough to put constant expression values into a read-only memory in cases like these:</p>
<pre><code class="language-cpp">vector&lt;int&gt; foo = {2,3,5,7,11};
</code></pre>
<p>the array containing the values would have a static life-time and reside in some read-only memory block.</p>
<p>In other cases we have non-literal types and dynamic initialization (like in your case) where a temporary array is created on the stack.</p>
<p>In any case, the life-time of the array is required to be at least as long as the life-time of the std::initializer object -- as far as I understand. I guess that copying the initializer_list object does not count and might produce a &quot;dangling initializer_list&quot; -- for example, if you return such a thing from a function. But then, what about RVO? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>In the case of the for-range loop we have the following situation:</p>
<pre><code class="language-cpp">auto&amp;&amp; range = {My(), My(), My()};
</code></pre>
<p>because the for-range loop is syntactic sugar which when expanded contains this kind of line of code. Deduction rules say that the declared type of <code>range</code> will be <code>initializer_list&lt;My&gt;&amp;&amp;</code> . Then, I would expect the life-time extension rule for temporary objects (the initializer_list object) to kick in. And since the life-time of the initializer_list object is extended to match the scope of <code>range</code> , the array this object refers to should also exist in this scope (and possibly beyond depending on whether it is possible to put it into a static read only block).</p>
<p>So, I guess your old G++ version gets it wrong.</p>
<p>Here's a workaround:</p>
<pre><code class="language-cpp">My range[] = {My(), My(), My()};
for (My const&amp; i : range) {
  cout &lt;&lt; i.x
}
</code></pre>
<p>(untested)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317374</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317374</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Mon, 22 Apr 2013 10:46:12 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Mon, 22 Apr 2013 11:01:27 GMT]]></title><description><![CDATA[<p>Come to think of it, your initializer list does not depend on any function parameters. But your element type has user-defined constructors and destructors. Does this mean that a compiler is allowed to implement</p>
<pre><code class="language-cpp">vector&lt;My&gt; foo()
{
  return {My(),My()};
}
</code></pre>
<p>like this</p>
<pre><code class="language-cpp">vector&lt;My&gt; foo()
{
  static My hidden_array[] = {My(),My()}; // static storage!
  return internal_array_to_ilist_detail(hidden_array);
}
</code></pre>
<p>or does it have to use an array on the stack such as</p>
<pre><code class="language-cpp">vector&lt;My&gt; foo()
{
  My hidden_array[] = {My(),My()}; // automatic storage!
  return internal_array_to_ilist_detail(hidden_array);
}
</code></pre>
<p>?</p>
<p>The difference is that in the first case, the initialization is only done once and destructors are called when the program ends.</p>
<p>Someone please explain the semantics of initializer_lists with respect to the elements life-time to me. Thanks.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317401</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317401</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Mon, 22 Apr 2013 11:01:27 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Mon, 22 Apr 2013 15:21:40 GMT]]></title><description><![CDATA[<p>n3337 schrieb:</p>
<blockquote>
<p>8.5.4 / 6<br />
The lifetime of the array is the same as that of the initializer_list object.</p>
</blockquote>
<p>g++ apparently doesn't consider 12.2/5 (and possibly 12.2/4) in this context so gets this wrong. That would be a bug (this part was in the draft at least from n2914 on - june 2009).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317448</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317448</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 22 Apr 2013 15:21:40 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Mon, 22 Apr 2013 16:06:26 GMT]]></title><description><![CDATA[<p>Lets have a look at the &quot;equivalence&quot; to every range-based for loop from the standard N3337 itself:</p>
<pre><code>{
    auto &amp;&amp; __range = range-init; // in our case, auto deduces to std::initializer_list (type of __range is std::initializer_list&lt;...&gt;&amp;&amp;)
    for ( auto __begin = begin-expr, // begin-expr is std::begin(__range)
               __end = end-expr;  // dito, std::end
         __begin != __end;
         ++__begin ) 
    {
        for-range-declaration = *__begin; // asignment
        statement // unimportant (can be compund-statement o.s.)
    }
}
</code></pre>
<p>Applied to our example:</p>
<pre><code>#include &lt;iostream&gt;

struct My
{
     My() { std::cout &lt;&lt; &quot;Constructed: &quot; &lt;&lt; this &lt;&lt; '\n'; }
    ~My() { std::cout &lt;&lt; &quot;Destructed: &quot;  &lt;&lt; this &lt;&lt; '\n'; }
};

int main()
{
    auto &amp;&amp; __range = {My(), My(), My()};
    for ( auto __begin = std::begin(__range),
               __end = std::end(__range);
         __begin != __end;
         ++__begin )
    {
        std::cout &lt;&lt; &quot;statement!\n&quot;;
    }
}
</code></pre>
<p>Now, what does this code print on GCC 4.8:</p>
<blockquote>
<p>Constructed: 0x22fe20<br />
Constructed: 0x22fe21<br />
Constructed: 0x22fe22<br />
statement!<br />
statement!<br />
statement!<br />
Destructed: 0x22fe22<br />
Destructed: 0x22fe21<br />
Destructed: 0x22fe20</p>
</blockquote>
<p>GCC 4.7.2 (from Ideone):</p>
<blockquote>
<p>Constructed: 0xbfef3b9d<br />
Constructed: 0xbfef3b9e<br />
Constructed: 0xbfef3b9f<br />
statement!<br />
statement!<br />
statement!<br />
Destructed: 0xbfef3b9f<br />
Destructed: 0xbfef3b9e<br />
Destructed: 0xbfef3b9d</p>
</blockquote>
<p>GCC 4.6.2:</p>
<blockquote>
<p>Constructed: 0x28ff0d<br />
Constructed: 0x28ff0e<br />
Constructed: 0x28ff0f<br />
Destructed: 0x28ff0f<br />
Destructed: 0x28ff0e<br />
Destructed: 0x28ff0d<br />
statement!<br />
statement!<br />
statement!</p>
</blockquote>
<p>What i don't understand is, how this is even possible. The init-list is destroyed, before i even iterate through it? Or could this be an optimization - but the question is, how could this be, why would newer compilers NOT optimize this... :head-scratch:</p>
<p>P.S.: SAn, do you use a 32-Bit Compiler on a 64-Bit machine?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317459</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317459</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Mon, 22 Apr 2013 16:06:26 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Mon, 22 Apr 2013 16:12:37 GMT]]></title><description><![CDATA[<p>Sone, what happens if you also log copy/move constructors and assignment operators?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317466</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317466</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Mon, 22 Apr 2013 16:12:37 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Mon, 22 Apr 2013 16:37:52 GMT]]></title><description><![CDATA[<p>Nexus schrieb:</p>
<blockquote>
<p>Sone, what happens if you also log copy/move constructors and assignment operators?</p>
</blockquote>
<p>Same shit.</p>
<pre><code>#include &lt;iostream&gt;

struct My
{
     My() { std::cout &lt;&lt; &quot;Constructed &quot; &lt;&lt; this &lt;&lt; '\n'; }
    ~My() { std::cout &lt;&lt; &quot;Destructed &quot;  &lt;&lt; this &lt;&lt; '\n'; }
    My(My const&amp; a) { std::cout &lt;&lt; &quot;Copied &quot;  &lt;&lt; &amp;a &lt;&lt; &quot; to &quot; &lt;&lt; this &lt;&lt; '\n'; }
    My(My&amp;&amp; a) { std::cout &lt;&lt; &quot;Moved &quot;  &lt;&lt; &amp;a &lt;&lt; &quot; to &quot; &lt;&lt; this &lt;&lt; '\n'; }
    My&amp; operator=(My&amp;&amp; a) { std::cout &lt;&lt; &quot;Move-assigned &quot;  &lt;&lt; &amp;a &lt;&lt; &quot; to &quot; &lt;&lt; this &lt;&lt; '\n'; return *this; }
    My&amp; operator=(My const&amp; a) { std::cout &lt;&lt; &quot;Assigned &quot;  &lt;&lt; &amp;a &lt;&lt; &quot; to &quot; &lt;&lt; this &lt;&lt; '\n'; return *this; }
};

int main()
{
    auto &amp;&amp; __range = {My(), My(), My()};
    for ( auto __begin = std::begin(__range),
               __end = std::end(__range);
         __begin != __end;
         ++__begin )
    {
        std::cout &lt;&lt; &quot;statement!\n&quot;;
    }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2317477</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317477</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Mon, 22 Apr 2013 16:37:52 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Mon, 22 Apr 2013 17:58:04 GMT]]></title><description><![CDATA[<p>It should be rather obvious what happens:</p>
<pre><code class="language-cpp">auto &amp;&amp; __range = {My(), My(), My()};
</code></pre>
<p>This creates 2 objects<br />
- a temporary initializer_list object<br />
- an array the initializer_list refers to<br />
If the initializer_list object was not bound to a reference as is the case here it would be destroyed at the end of the initialization (=full expression, 12.2/3).<br />
Because the initializer_list is actually bound to a reference its lifetime is extended to the lifetime of the reference, i.e. its scope.<br />
The array refered to by the initializer_list object is required to have the same lifetime, but g++ 4.6.3 does not do this correctly.</p>
<pre><code class="language-cpp">auto range = {My(), My(), My()};
</code></pre>
<p>works, because here the lifetime of the initializer_list is automatic in the first place.<br />
Despite the syntax this does not involve an elided copy of a initializer_list object, and if it did, the lifetime of the array would be too short.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317501</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317501</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 22 Apr 2013 17:58:04 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Tue, 23 Apr 2013 18:57:21 GMT]]></title><description><![CDATA[<p>The Clang has similar problem too.</p>
<p>You say about some array. I thought the initialiser list</p>
<pre><code>auto a = {4, 3, 2, 1};
</code></pre>
<p>is equal to something like that:</p>
<pre><code>std::initializer_list&lt;int, 4&gt; const a(4, 3, 2, 1);
</code></pre>
<p>Now I suspect the following:</p>
<pre><code>int const t[] = {4, 3, 2, 1};
std::initializer_list&lt;int&gt; const a(t, t + 4);
</code></pre>
<p>Am I right?</p>
<p>The bug was discovered by our female coworker. She wrote something like that:</p>
<pre><code>void process(cv::Mat &amp;image1, cv::Mat &amp;image2, cv::Mat &amp;image3)
{ //cv::Mat is OpenCV image. On object copy it copies only header (image data is reference counted).
  for ( cv::Mat &amp;image: {image1, image2, image3} )
  {
    ...do some common preprocessing...
  }

  ...do specific processing for image1...
  ...do specific processing for image2...
  ...do specific processing for image3... 
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2317874</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317874</guid><dc:creator><![CDATA[SAn]]></dc:creator><pubDate>Tue, 23 Apr 2013 18:57:21 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Tue, 23 Apr 2013 19:17:44 GMT]]></title><description><![CDATA[<blockquote>
<p>Am I right?</p>
</blockquote>
<p>Nope. The Array is internal. (Btw, <code>initializer_list</code> has no such ctor)</p>
<blockquote>
<p>std::initializer_list&lt;int, 4&gt; const a(4, 3, 2, 1);</p>
</blockquote>
<p>What you mean is <code>std::array</code> (and it uses aggregate initialization, which requires <strong>curled</strong> braces)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317886</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317886</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Tue, 23 Apr 2013 19:17:44 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Tue, 23 Apr 2013 19:21:51 GMT]]></title><description><![CDATA[<p>Ich habe mich zwar bisher zurückgehalten, aber jetzt ist das Fass übergelaufen.</p>
<p>Ist es wirklich nötig, dass <strong>deutsche User</strong> in einem <strong>deutschen</strong> Forum englisch Reden?</p>
<p>Es gibt genug englische Programmier-Foren, und, ich sage das jetzt ungern, die sind z. T. noch besser als dieses hier.</p>
<p>Ach ja: und noch besser ist es natürlich, wenn man einen Thread mit englischem Titel erstellt, und in deutsch diskutiert. So stoßen Englischspracheige über google auf diesen Thread und verstehen nichts. Aber das nur nebenbei.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317888</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317888</guid><dc:creator><![CDATA[Was gesagt werden muss]]></dc:creator><pubDate>Tue, 23 Apr 2013 19:21:51 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Tue, 23 Apr 2013 19:28:53 GMT]]></title><description><![CDATA[<p>SAn schrieb:</p>
<blockquote>
<p>Now I suspect the following:</p>
<pre><code>int const t[] = {4, 3, 2, 1};
std::initializer_list&lt;int&gt; const a(t, t + 4);
</code></pre>
<p>Am I right?</p>
</blockquote>
<p>in essence (pseudo-code). Of course, if the initializer_list ist created implicitely it is temporary as is the the array it referes to. It's the compiler's job to keep them in sync.</p>
<p>Copying an initializer_list does not copy the array it uses nor does it magically extend the lifetime of said array. Doing so in a situation where the copy might outlive the original (for example: storing one in a container) is a bad idea.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317891</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317891</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 23 Apr 2013 19:28:53 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Tue, 23 Apr 2013 19:35:43 GMT]]></title><description><![CDATA[<blockquote>
<p>Copying an initializer_list does not copy the array it uses nor does it magically extend the lifetime of said array.</p>
</blockquote>
<p>WTF?<br />
That can't be true. Whait a sec.</p>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> <a href="http://ideone.com/MMSJNJ" rel="nofollow">http://ideone.com/MMSJNJ</a><br />
<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> <a href="http://ideone.com/RGvAP1" rel="nofollow">http://ideone.com/RGvAP1</a><br />
So what are you talking about?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317893</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317893</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Tue, 23 Apr 2013 19:35:43 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Tue, 23 Apr 2013 19:44:36 GMT]]></title><description><![CDATA[<p>Sone schrieb:</p>
<blockquote>
<blockquote>
<p>Copying an initializer_list does not copy the array it uses nor does it magically extend the lifetime of said array.</p>
</blockquote>
<p>WTF?<br />
That can't be true. Whait a sec.</p>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> <a href="http://ideone.com/MMSJNJ" rel="nofollow">http://ideone.com/MMSJNJ</a><br />
<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> <a href="http://ideone.com/RGvAP1" rel="nofollow">http://ideone.com/RGvAP1</a><br />
So what are you talking about?</p>
</blockquote>
<p>what did you prove?<br />
consider <a href="http://ideone.com/ftEcyd" rel="nofollow">http://ideone.com/ftEcyd</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317896</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317896</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 23 Apr 2013 19:44:36 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Tue, 23 Apr 2013 19:45:04 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>Sone schrieb:</p>
<blockquote>
<blockquote>
<p>Copying an initializer_list does not copy the array it uses nor does it magically extend the lifetime of said array.</p>
</blockquote>
<p>WTF?<br />
That can't be true. Whait a sec.</p>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> <a href="http://ideone.com/MMSJNJ" rel="nofollow">http://ideone.com/MMSJNJ</a><br />
<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> <a href="http://ideone.com/RGvAP1" rel="nofollow">http://ideone.com/RGvAP1</a><br />
So what are you talking about?</p>
</blockquote>
<p>what did you prove?</p>
</blockquote>
<p>That the array the initializer_list is using, is indeed copied. Which is the exact opposite of what you said. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /></p>
<p>But apparently i didn't prove anything?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317899</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317899</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Tue, 23 Apr 2013 19:45:04 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Tue, 23 Apr 2013 19:48:30 GMT]]></title><description><![CDATA[<p>Sone schrieb:</p>
<blockquote>
<p>But apparently i didn't prove anything?</p>
</blockquote>
<p>I trust you do know what undefined behaviour is.<br />
For example, to <a href="http://ideone.com/DX7365" rel="nofollow">pick over the dead bones</a>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317902</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317902</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 23 Apr 2013 19:48:30 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Tue, 23 Apr 2013 19:46:28 GMT]]></title><description><![CDATA[<p>Oh wait! The stack is not overriden, thus the values stay the same? ... or what ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317903</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317903</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Tue, 23 Apr 2013 19:46:28 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Tue, 23 Apr 2013 19:50:48 GMT]]></title><description><![CDATA[<p>N3337 18.9 / 1</p>
<blockquote>
<p>Copying an initializer list does<br />
not copy the underlying elements.</p>
</blockquote>
<p>g'dammit</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317906</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317906</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Tue, 23 Apr 2013 19:50:48 GMT</pubDate></item><item><title><![CDATA[Reply to Weird behavior of range-based for on Wed, 24 Apr 2013 10:32:52 GMT]]></title><description><![CDATA[<p>Sone schrieb:</p>
<blockquote>
<p>N3337 18.9 / 1</p>
<blockquote>
<p>Copying an initializer list does<br />
not copy the underlying elements.</p>
</blockquote>
<p>g'dammit</p>
</blockquote>
<p>That's only a note though. You might want to read 8.5.4/5 et seq. to figure out how to derive that answer from the normative text (hint: consider what's <em>not</em> written in there).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2318014</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2318014</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Wed, 24 Apr 2013 10:32:52 GMT</pubDate></item></channel></rss>