Implement C23 memalignment

Joseph Myers josmyers@redhat.com
Thu Oct 2 17:51:39 GMT 2025


On Thu, 2 Oct 2025, Zack Weinberg wrote:

> | On all presently supported systems, when @var{A} is a power of two,
> | @code{memalignment (@var{P}) == @var{A}} is equivalent to
> | @code{((uintptr_t) @var{P}) & (@var{A - 1})}.  If @var{A} is certain

That's not equivalent.  The expression with '&' tests for *not* having 
alignment A.  The expression with memalignment tests for having alignment 
*exactly* A (not allowing greater alignment, or alignment 0 for the null 
pointer case).

-- 
Joseph S. Myers
josmyers@redhat.com



More information about the Libc-alpha mailing list