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 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/man/man3/aligned_alloc.3 b/man/man3/aligned_alloc.3 index cdc9ba1a2..0c9a12787 100644 --- a/man/man3/aligned_alloc.3 +++ b/man/man3/aligned_alloc.3 @@ -76,6 +76,35 @@ .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, +such as OpenBSD. +However, +in those implementations, +the function reports an error, +and don't exploit the UB. +It was only a theoretical 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

