And document that OpenBSD still implements the C11 specification (but without the UB).
Fixes: 7fd1e0f2be21 (2023-05-20; "posix_memalign.3: Update aligned_alloc(3) to match C17") Reported-by: Eugene Syromyatnikov <[email protected]> Cc: Seth McDonald <[email protected]> Cc: DJ Delorie <[email protected]> Cc: John Scott <[email protected]> Cc: Paul Floyd <[email protected]> Cc: <[email protected]> Cc: Ingo Schwarze <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]> --- man/man3/aligned_alloc.3 | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/man/man3/aligned_alloc.3 b/man/man3/aligned_alloc.3 index cdc9ba1a2..f5fad3654 100644 --- a/man/man3/aligned_alloc.3 +++ b/man/man3/aligned_alloc.3 @@ -76,6 +76,46 @@ .SH HISTORY glibc 2.16. C11, POSIX.1-2024. +.SS C11 +In C11, +the specification of this function had several issues. +.IP \[bu] 3 +.I size +had to be a multiple of +.IR alignment . +Otherwise, +the behavior was undefined. +.IP +Some implementations still implement that restriction, +or claim to have it. +.RS +.TP +OpenBSD +The function reports an error +if this restriction is violated, +without exploiting the UB. +.TP +FreeBSD +.TQ +jemalloc +The documentation claims to have this restriction, +but the implementation works correctly if it is violated. +.RE +.IP +It was only a theoretical UB. +No known implementation has ever exploited this UB. +.IP +This restriction was removed in C17. +.IP \[bu] +If +.I alignment +was not a power of two, +the behavior was undefined. +.IP +No implementations ever exploited this UB. +It was only a theoretical UB. +.IP +This UB was removed in C17. .SH NOTES On many systems there are alignment restrictions, for example, on buffers used for direct block device I/O. -- 2.51.0

