title: Does the order of operations change within an if expression?
body: <p>I recently came across something that I thought I understood right off the bat, but thinking more on it I would like understanding on why it works the way it does.</p>
  
  <p>Consider the code below. The <code>(x-- == 9)</code> is clearly getting evaluated, while the <code>(y++ == 11)</code> is not. My first thought was that logical <code>&amp;&amp;</code> kicks in, sees that the expression has already become false, and kicks out before evaluating the second part of the expression.</p>
  
  <p>The more I think about it, the more I don't understand why this behaves as it does. As I understand it, logical operators fall below increment operations in the order of precedence. Shouldn't <code>(y++ == 11)</code> be evaluated, even though the overall expression has already become false?</p>
  
  <p>In other words, shouldn't the order of operations dictate that <code>(y++ == 11)</code> be evaluated before the <code>if</code> statement realizes the expression as a whole will be false?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main( int argc, char** argv )
  {
      int x = 10;
      int y = 10;
  
      if( (x-- == 9) &amp;&amp; (y++ == 11) )
      {
          cout &lt;&lt; "I better not get here!" &lt;&lt; endl;
      }
  
      cout &lt;&lt; "Final X: " &lt;&lt; x &lt;&lt; endl;
      cout &lt;&lt; "Final Y: " &lt;&lt; y &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Final X: 9
  Final Y: 10
  </code></pre>