Topic: Summary about alignement & C++ memory model
Author: Valentin Bonnard <bonnardv@pratique.fr>
Date: 1997/11/07 Raw View
I have posted a question here about alignment; I got a
some answers by mail and followups. I'll summary the
question, and I'll try to annalyse the problem.
The question was: what does alignment means from a standard
point of view ? What can/can't you do in conforming code
because of this notion ? Can you justify your opinion about
alignment with an extract from the standard ?
I don't care if some code which has undefined behaviour, and
so is unportable works fastly on a 68020 than on 8086. That's
_not_ the point here (we are in comp.STD.c++).
I cc this article to Josee Lajoie to get her opinion on
that.
Alignment seems important in two cases:
(1) when reinterpret_casting a pointer to A to pointer to B,
where B has stronger alignment requirements
(2) when reading/writing through a pointer to a type
different from the declared type
I'll handle these issues one by one:
(1) reinterpret_casting to stronger alignment requirement