title: Strange pointer arithmetic
body: <p>I came across too strange behaviour of pointer arithmetic. I am developing a program to develop SD card from LPC2148 using ARM GNU toolchain (on Linux). My SD card a sector contains data (in hex) like (checked from linux "xxd" command):
  fe 2a 01 34       21 45 aa 35       90 75 52 78
  While printing individual byte, it is printing perfectly.</p>
  
  <pre><code>char *ch = buffer; /* char buffer[512]; */
  for(i=0; i&lt;12; i++)
      debug("%x ", *ch++);
  </code></pre>
  
  <p>Here debug function sending output on UART.
  However pointer arithmetic specially adding a number which is not multiple of 4 giving too strange results.
      uint32_t *p;   // uint32_t  is typedef to unsigned long.</p>
  
  <pre><code>p = (uint32_t*)((char*)buffer + 0);
  debug("%x ", *p);   // prints 34012afe   // correct
  
  p = (uint32_t*)((char*)buffer + 4);
  debug("%x ", *p);   // prints 35aa4521  // correct
  
  p = (uint32_t*)((char*)buffer + 2);
  debug("%x ", *p);   // prints 0134fe2a  // TOO STRANGE??
  </code></pre>
  
  <p>Am I choosing any wrong compiler option? Pls help.
  I tried optimization options -0 and -s; but no change.</p>
  
  <p>I could think of little/big endian, but here i am getting unexpected data (of previous bytes) and no order reversing.</p>