title: Why compilers no longer optimize this UB with strict aliasing
body: <p>One of the first results for strict aliasing on google is this article
  <a href="http://dbp-consulting.com/tutorials/StrictAliasing.html">http://dbp-consulting.com/tutorials/StrictAliasing.html</a><br>
  One interesting thing I noticed is this: <a href="http://goo.gl/lPtIa5">http://goo.gl/lPtIa5</a></p>
  
  <pre><code>uint32_t swaphalves(uint32_t a) {
    uint32_t acopy = a;
    uint16_t* ptr = (uint16_t*)&amp;acopy;
    uint16_t tmp = ptr[0];
    ptr[0] = ptr[1];
    ptr[1] = tmp;
    return acopy;
  }
  </code></pre>
  
  <p>is compiled to</p>
  
  <pre><code>swaphalves(unsigned int):
          mov     eax, edi
          ret
  </code></pre>
  
  <p>by GCC 4.4.7. Any compiler newer than that (4.4 is mentioned in the article so article is not wrong) does not implement the function as it could using strict aliasing. 
  What is the reason for this? 
  Was it in fact bug in GCC or GCC decided to drop it since many lines of code were written in a way that thay produce UB  or it is just a compiler regression that lasts for years... 
  Also Clang does not optimize it. </p>