title: The difference between asm, asm volatile and clobbering memory
body: <p>When implementing lock-free data structures and timing code it's often necessary to suppress the compiler's optimisations. Normally people do this using <code>asm volatile</code> with <code>memory</code> in the clobber list, but you sometimes see just <code>asm volatile</code> or just a plain <code>asm</code> clobbering memory.</p>
  
  <p>What impact do these different statements have on code generation (particularly in GCC, as it's unlikely to be portable)?</p>
  
  <p>Just for reference, these are the interesting variations:</p>
  
  <pre><code>asm ("");   // presumably this has no effect on code generation
  asm volatile ("");
  asm ("" ::: "memory");
  asm volatile ("" ::: "memory");
  </code></pre>