This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Does malloc tell us anything about alignment modulo k?


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)?

Hi.


In the glibc docs you can find these sentences (which I have always trusted):

Allocating Aligned Memory Blocks
................................

The address of a block returned by `malloc' or `realloc' in the GNU
system is always a multiple of eight (or sixteen on 64-bit systems).
If you need a block whose address is a multiple of a higher power of
two than that, use `memalign', `posix_memalign', or `valloc'.
...

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]