In Annex M of this draft, I found:
added
memalignment
function to query the alignment of a pointer;
and then its documentation:
7.24.9 Alignment of memory
7.24.9.1 Thememalignment
functionSynopsis
#include <stdlib.h> size_t memalignment(const void *p);
Description
The
memalignment
function accepts a pointer to any object and returns the maximum
alignment satisfied by its address value. The alignment may be an
extended alignment and may also be beyond the range supported by the
implementation for explicit use byalignas
. 359) If so, it will
satisfy all alignments usable by the implementation. The value
returned can be compared to the result ofalignof
, and if it is
greater or equal, the alignment requirement for the type operand is
satisfied.Returns
The alignment of the pointer p, which is a power of two. If p is a null pointer, an alignment of zero is returned.
NOTE
An alignment of zero indicates that the tested pointer cannot be
used to access an object of any type.
Question: What do “maximum alignment” and “extended alignment” mean in layman’s terms, and can’t the alignment of a pointer be found with the alignof
operator?
1