I not understood suitable pointer alignment concept:
There are no constraints on the contents of the allocated storage on
return from the allocation function. The order, contiguity, and
initial value of storage allocated by successive calls to an
allocation function are unspecified. The pointer returned shall be
suitably aligned so that it can be converted to a pointer of any
complete object type with a fundamental alignment requirement (3.11)
and then used to access the object or array in the storage allocated
(until the storage is explicitly deallocated by a call to a
corresponding deallocation function).
There is no definition of suitable alignment in the sec.3.11. You explain that should mean?
Answer
This means that for any complete object type with a fundamental alignment, it should be possible to convert the pointer returned to a pointer to that object type, respecting the alignment requirement of that object type.
In practice, since alignments are powers of two, this means that an allocation function is required to return a pointer aligned to alignof(std::max_align_t)
.
There is no separate definition of "suitable alignment"; in this paragraph as elsewhere "suitably" just means that there is a requirement which the program is required to satisfy for the rest of the paragraph to hold.
No comments:
Post a Comment