title: Why I got "operation may be undefined" in Statement Expression in C++?
body: <p>to describe the problem simply, please have a look at the code below:</p>
  
  <pre><code>int main()
  {
      int a=123;
      ({if (a) a=0;});
      return 0;
  }
  </code></pre>
  
  <p>I got this warning from [-Wsequence-point]</p>
  
  <pre><code>Line 4: warning: operation on 'a' may be undefined
  </code></pre>
  
  <p>my g++ version is 4.4.5</p>
  
  <p>I'll appreciate whoever would explain this simple problem.</p>
  
  <p>btw you could find my original program and original problem in #7 in <a href="http://bbs.csdn.net/topics/390475508" rel="nofollow noreferrer" title="this">this</a> Chinese site (not necessary)</p>
  
  <p><strong>UPD1:</strong></p>
  
  <p>though to change the code into <code>({if(a) a=0; a;})</code> can avoid the warning, but I recognized that the real reason of the problem may not be <code>The last thing in the compound statement should be an expression followed by a semicolon</code>.</p>
  
  <p>because the documentary also said <code>If you use some other kind of statement last within the braces, the construct has type void, and thus effectively no value</code>.</p>
  
  <p>an example can show it:</p>
  
  <pre><code>int main()
  {
      int a=123, b;
      ({;});
      ({if (a) b=0;});
      return 0;
  }
  </code></pre>
  
  <p>and this code got <strong>no warnings</strong>!
  so I think the real reason is something about sequence point.</p>
  
  <p>please help!</p>
  
  <p><strong>UPD2:</strong></p>
  
  <p>sorry to @AndyProwl for having unaccept his answer which was accepted before UPD1. following his advise I may ask a new question (UPD1 is a new question different from the original one). I'll accept  his answer again because it surely avoids warnings anyhow.:)</p>
  
  <p>If I decided to ask a new question, I'll update this question to add a link.</p>