Does casting a char array to another type violate strict-aliasing rules? : <p>Consider these two functions:</p>

<pre><code>int f1()
{
  alignas(int) char buf[sizeof(int)] = {};
  return *reinterpret_cast&lt;int*&gt;(buf);
}

int f2()
{
  alignas(int) char buf[sizeof(int)] = {};
  char* ptr = buf;
  return *reinterpret_cast&lt;int*&gt;(ptr);
}
</code></pre>

<p>GCC warns that the first violates strict-aliasing rules.  But the second is OK.</p>

<p>Clang accepts both without complaint.</p>

<p>Is the warning legitimate?</p>
