[Bug malloc/20137] aligned_alloc should fail for bad size / alignment [DR#460]
joseph at codesourcery dot com
sourceware-bugzilla@sourceware.org
Wed May 25 10:59:00 GMT 2016
https://sourceware.org/bugzilla/show_bug.cgi?id=20137
--- Comment #2 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Wed, 25 May 2016, fweimer at redhat dot com wrote:
> --- Comment #1 from Florian Weimer <fweimer at redhat dot com> ---
> (In reply to Joseph Myers from comment #0)
> > The resolution to C11 DR#460 requires aligned_alloc to return NULL if the
> > alignment is not valid (not a power of 2, in our case) or the size is not a
> > multiple of the alignment. This needs to be implemented.
>
> Do you have link to the rationale for the second requirement? It does not make
> sense to me.
I think requiring failure, given that this case is not defined, is about
avoiding unnecessary undefined behavior.
I don't see anything in N1397 (the original addition of aligned_alloc)
about why the size was required to be a multiple of the alignment in the
first place; I'd guess it's general principles about sizes of types always
being multiples of their alignment. aligned_alloc would be expected to be
used with extensions such as vector types, given that it's not needed for
any standard type.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Glibc-bugs
mailing list