Now, after Peter's and Berend's answers I'm a bit confused... Could someone clear things up for me, please?
Note, I'm talking about gpc, not about other compilers or about the standard.
Peter Gerwinski wrote:
Why is this so, e.g. with an array of something which has 3 bytes?
Program Test; Type r = packed record x: ShortWord; y: Byte; end (* r *); Var x: packed array [ 1..1000 ] of r; begin writeln ( SizeOf ( x ) ); writeln ( SizeOf ( x [ 1 ] ) ); end.
The output is 4000 and ... 4. To avoid alignment problems in an "array of r", the record `r' has size 4, not 3.
BTW: Does this mean if you have
var a:r; b:byte;
then 1 byte after a will be "wasted" though b could fit into it? It has to be so if sizeof(a)=4, if someone does "move(...,a,sizeof(a))".