MAX_MALLOC_ALIGN and libc spec

Almaz Mingaleev mingaleev at google.com
Fri Nov 14 10:42:09 UTC 2025


Hello,

SegmentFactories defines MAX_MALLOC_ALIGN variable and sets it to 16 on
LP64 architectures. However, section 7.24.4.1 of the libc spec only says

> The pointer returned if the allocation succeeds is suitably aligned so
that it can be
> assigned to a pointer to any type of object with a fundamental alignment
> requirement and size less than or equal to the size requested

(https://open-std.org/JTC1/SC22/WG14/www/docs/n3467.pdf#page=397)

The largest type defined by the spec seems to be “long double” and there is
only “Recommended practice” for it:

> The long double type should match the ISO/IEC 60559 binary128 format, else
> an ISO/IEC 60559 binary64-extended format.

Do I understand correctly that the currently used value of 16 is relying on
existing implementations and that the current implementation might
misbehave if a malloc call for a size of 8 bytes returns an 8 bytes aligned
address, which is allowed by the spec?

Also, shouldn’t the name be MIN_MALLOC_ALIGN?

Thanks,
Almaz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20251114/54645a5d/attachment.htm>


More information about the panama-dev mailing list