On Jan 17, 2007, at 5:23 AM, Inder wrote:
void make(char* a) { *(unsigned long*)a = 0x12345678; }
stating address of the char array now starts from an unaligned
address and is acessed by the instruction
strb r3, [fp, #-26]
which gives a very wrong result
Is the compiler doing a right thing or is it a bug?
You asked for char alignment, and your program requires long
alignment, your program is now, and always has been buggy. The
manual covers how to fix this, if you want to use __attribute__,
otherwise, you can use a union to force any alignment you want. So,
in your case, yes, the compiler is doing the right thing.
If you were on a processor that handled misaligned data slowly, and
you saw a general performance drop because of this, I'd encourage you
to file a bug report as it might be a bug, if the results you see
apply generally.
You're asking about behavioral differences in compilers that are
really old. You increase the odds that you can have these types of
questions answered here, if you track and test mainline and ask the
week the behavior changes, if it isn't obvious from glancing at the
list for the past week. :-)