|
|
ollemblomgren@xxxxxxxxx wrote:
I write this program but it doesn't crash. Is it because I'm testing
the wrong thing (my understanding is wrong) or is it because my
environment is very forgiving?
There's no such thing as some mandatory "word alignment". Alignment
requirements are type-specific and platform-specific. It is quite
possible that in your platform objects of type 'int' can be placed in
memory in any way you want, i.e. there are no alignment restrictions as all.
Note also, that the real "platform" you are working with is really the
platform provided (emulated) by the compiler. It doesn't necessarily
have to inherit all (or any) requirements from the underlying hardware
platform. Normally it does for performance reasons, but it is not
impossible to implement a C compiler that wouldn't impose any alignment
restrictions on any of its data types, even though the underlying
hardware platform does have such restriction for "corresponding"
hardware data types.
--
Best regards,
Andrey Tarasevich
|
|