title: Why would you use the ternary operator without assigning a value for the "true" condition (x = x ?: 1)
body: <p>In the Android open-source qemu code I ran across this line of code:</p>
  
  <pre><code>machine-&gt;max_cpus = machine-&gt;max_cpus ?: 1; /* Default to UP */
  </code></pre>
  
  <p>Is this just a confusing way of saying:</p>
  
  <pre><code>if (machine-&gt;max_cpus) {
     ; //do nothing
  } else {
   machine-&gt;max_cpus = 1;
  }
  </code></pre>
  
  <p>If so, wouldn't it be clearer as:</p>
  
  <pre><code>if (machine-&gt;max_cpus == 0) machine-&gt;max_cpus = 1;
  </code></pre>
  
  <p>Interestingly, this compiles and works fine with gcc, but doesn't compile on <a href="http://www.comeaucomputing.com/tryitout/" rel="noreferrer">http://www.comeaucomputing.com/tryitout/</a> .</p>