title: compiler reordering and load operation
body: <p>I'm starting lock free programming and I encounter some difficulties for basic stuff. I have found the following example :</p>
  
  <pre><code>#define COMPILER_BARRIER() asm volatile("" ::: "memory")
  
  int Value;
  int IsPublished = 0;
  
  void sendValue(int x)
  {
      Value = x;
      COMPILER_BARRIER();          // prevent reordering of stores
      IsPublished = 1;
  }
  
  int tryRecvValue()
  {
      if (IsPublished)
      {
          COMPILER_BARRIER();      // prevent reordering of loads
          return Value;
      }
      return -1;  // or some other value to mean not yet received
  }
  </code></pre>
  
  <p>What kind of reordering a compiler can perform in <code>tryRecvValue</code>  function ?</p>