[Python-Dev] GC head alignment issue (original) (raw)

Guido van Rossum guido@python.org
Fri, 12 Oct 2001 15:06:12 -0400


I have anuther issue with the change tho: as written, it forces the struct (it's only a union by accident) gchead to be aligned, but is it obvious that it really has to pad up the size too ?

Yes.

If for example sizeof (int) is 4, sizeof (struct *) is 8 and sizeof (double) is 16, with 8 byte alignment required for doubles, would a compiler be allowed to make sizeof (struct gchead[1]) 24, while still keeping sizeof (struct gchead) at 20 ?

No. Each item in an array has to be aligned, so the sizeof a struct must be a multiple of the largest required alignment for any of its items. It's all spelled out in the C standard, so don't worry.

--Guido van Rossum (home page: http://www.python.org/~guido/)