title: GCC considers int pointers unaligned on ARM
body: <p>I have the following test program:</p>
  
  <pre><code>#include &lt;string.h&gt;
  int q(int *p) {
      int x;
      memcpy(&amp;x,p,sizeof(int));
      x+=12;
      memcpy(p,&amp;x,sizeof(int));
      return p[0];
  }
  </code></pre>
  
  <p>When I compile this using GCC 4.7.2 for arm-linux-gnueabihf, the compiler suspects that the pointer accesses may be unaligned, annotating the loads and stores in the assembly output, for example:</p>
  
  <pre><code>    ldr     r0, [r0, #0]    @ unaligned
  </code></pre>
  
  <p>If I compile with <code>-mno-unaligned-access</code>, the compiler does not emit direct loads and stores at all but calls the library <code>memcpy</code> instead. But in fact, the pointers in this case should never be unaligned. Is this an overlook in gcc, or am I mistaken?</p>