Inder wrote:
Hi All
I have similar question as for arm
http://gcc.gnu.org/ml/gcc/2007-01/msg00691.html
consider the following program.
e.g..
----------------- align.c -----------------
int main()
{
int bc;
char a[6];
int ac;

bc = 0xffffffff;
/* fill with zeros.  */
a[0] = 0x00;
a[1] = 0x01;
 a[2] = 0x02;
  a[3] = 0x03;
   a[4] = 0x04;
    a[5] = 0x05;
ac=0xeeeeeeee;
make(a);
}
void make(char* a)
{
*(unsigned long*)a = 0x12345678;
}

Is the compiler doing a right thing or is it a bug??

Your code is not Standard C.

If you want to treat the same memory locations as
different data types, use a union:

  union {
    long l;
    char c[4];
  } a;

  a.l = 0x12345678;
  a.c[0] = 0x01;

--
Michael Eager    [EMAIL PROTECTED]
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077

Reply via email to