C
CBFalconer
Robert said:7.20.3p1 sentence 2:
"The pointer returned if the allocation succeeds is suitably
aligned so that it may be assigned to a pointer to any type
of object and then usedto access such an object or an array
of such objects in the space allocated (until the space is
explicitly deallocated)."
I'm not sure why, the Rationale doesn't give any hints here. It
doesn't particularly make sense that the allocated space must be
aligned to store an object that could not fit into the space,
perhaps there is another reason we are overlooking or maybe I'm
misinterpreting the above quote.
The malloc subsystem doesn't know, and can't know, what type the
pointer will be used for. It returns a void*, and the only
information it gets is the size required. That size may be for one
item, or for many items.
Similarly the application has no information as to the alignment
requirements for a type. The compiler system does. That is one of
the fundamental reasons that malloc is a system function, and
simply cannot be written in purely portable code.
--
Some informative links:
http://www.geocities.com/nnqweb/
http://www.catb.org/~esr/faqs/smart-questions.html
http://www.caliburn.nl/topposting.html
http://www.netmeister.org/news/learn2quote.html