This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Does malloc tell us anything about alignment modulo k?
- From: Jeffrey A Law <law at redhat dot com>
- To: Daniel Berlin <dberlin at dberlin dot org>
- Cc: "gcc at gcc dot gnu dot org list" <gcc at gcc dot gnu dot org>
- Date: Thu, 15 Jul 2004 08:50:32 -0600
- Subject: Re: Does malloc tell us anything about alignment modulo k?
- Organization: Red Hat, Inc
- References: <3F979366-D66C-11D8-A090-000A95DA505C@dberlin.org>
- Reply-to: law at redhat dot com
On Thu, 2004-07-15 at 08:35, Daniel Berlin wrote:
> I'm working on some trivial alignment analysis.
> Malloc'd memory is supposed to be "aligned suitably for any data type".
> Does this actually tell us anything about whether the result is aligned
> modulo k (IE aligned to a k byte boundary)?
>
> Some OS'en seem to have stricter guarantees (Darwin guarantees the
> result of malloc is 16 byte aligned), i'm just trying to figure out
> whether the general case tells us anything.
You can assume the return value from malloc is aligned to
BIGGEST_ALIGNMENT. GCC has done this for some time.
jeff