https://bugs.kde.org/show_bug.cgi?id=446754

--- Comment #1 from Paul Floyd <pjfl...@wanadoo.fr> ---
On Linux aligned_alloc accepts an alignment of 0 and an alignment of 40 (i.e., 
not a power of 2). So the man page is wrong. In fact everything that the man
page says about errors concerning alignment/size is wrong.

Looking here

https://elixir.bootlin.com/glibc/latest/source/malloc/malloc.c#L3416

If the alignment is less than MALLOC_ALIGNMENT (which is 16 for i386 and the
max(2*sizeof(size_t), sizeof(long double)) on other platforms) then it just
calls the malloc implementation, no error.

Not in the man page but in the source there is a check that alignment is not
over half the max value of size_t. That causes EINVAL.

Lastly if the alignment is not a power of 2 it gets bumped up to the next power
of 2, no error.

There is no check that size is a multiple of alignment.

What a nightmare.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to