title: Is this code behavior defined?
body: <p>What does the following code print to the console?</p>
  
  <pre><code>map&lt;int,int&gt; m;
  m[0] = m.size();
  printf("%d", m[0]);
  </code></pre>
  
  <p>Possible answers:</p>
  
  <ol>
  <li>The behavior of the code is not defined since it is not defined which statement <code>m[0]</code> or <code>m.size()</code> is being executed first by the compiler. So it could print <code>1</code> as well as <code>0</code>.</li>
  <li>It prints <code>0</code> because the right hand side of the assignment operator is executed first.</li>
  <li><p>It prints <code>1</code> because the <code>operator[]</code> has the highest priority of the complete statement <code>m[0] = m.size()</code>. Because of this the following sequence of events occurs:</p>
  
  <ul>
  <li><code>m[0]</code> creates a new element in the map</li>
  <li><code>m.size()</code> gets called which is now <code>1</code></li>
  <li><code>m[0]</code> gets assigned the previously returned (by m.size()) <code>1</code>  </li>
  </ul></li>
  <li><p><em>The real answer?</em>, which is unknown to me^^</p></li>
  </ol>