On 10/25/21 08:45, Martin Sebor via Libc-alpha wrote: > Based on my code inspection of _mid_memalign in malloc.c I think > a change that would more accurately reflect the implementation > is one that described that when alignment is not a power of two > it's bumped up to next larger power of two, and adjusted > the EINVAL condition appropriately. Let's not document this implementation detail, as it might tie us down unnecessarily in the future. > I believe the DR460 change went into C17. Here's an early C2x > draft from 2018 publicly available on the WG14 site that should > still be very close to C17: > > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf This says that aligned_alloc "shall fail" if the alignment is not a valid alignment supported by the implementation. This means the current glibc alloc_aligned behavior does not conform to C17 and should be fixed so that it does. Something like the attached (untested) patch, say.