byte aligned to odd address. Does it violate access boundary theory?
stru开发者_如何学Cct X {
char a;
char b;
int c;
};
In the above struct, member b
is stored in an odd address. I checked this on a linux/x86 enviroment
Many web pages talks about inability of processors to access odd addresses. If it was true, then there should been padding of 1 byte between member a
and b
, such that b
is stored in an even address.
What am I missing?
Acessing a char at an odd address is always okay. However, an int at an odd address could cause a problem. However, the compiler will automatically add padding to between struct fields if needed. I'm assuming C/C++ as your language.
精彩评论