This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: improving malloc
On Sat, 5 Jan 2013, Rich Felker wrote:
> Read the text of the response
> (http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_075.html). The
> requirement is only that (void *)(T *)p == p for any p returned by
> malloc. This is true even if the pointer is not aligned in the "value
No, that's just an example from the question and the answer; the
requirement is to be suitably aligned for any (standard) type.
> observe whether they are or not. In particular, since the value of
> casts from pointers to integers are implementation-defined, there is
I.e. as defined in GCC's implement-c.texi.
> no requirement that (uintptr_t)p & (1<<MAX_ALIGN)-1 == 0, even though
Such a requirement follows from the implementation definition of
pointer-to-integer casts together with the alignment requirements
specified in the C ABI for the architecture in question (or, for that
matter, from how the ABI defines the representation of pointers together
with the alignment requirements in the ABI, without regard for
pointer-to-integer casts).
--
Joseph S. Myers
joseph@codesourcery.com