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?


On Thu, 15 Jul 2004, Geoffrey Keating wrote:

> In general, if malloc(x) is called, and a type exists on the target
> whose size is no more than x and which has alignment y, then the
> result of the malloc also has alignment at least y.
> 
> So, for instance, you can deduce that malloc(16) on Darwin is 16-byte
> aligned.  You can't deduce the same for malloc(2), but it's not clear
> how knowing that's alignment would be useful anyway.

The answer to C90 DR #075 says that being suitably aligned for any type
includes for types larger than the amount of memory allocated.  As you
say, this probably isn't particularly useful.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)


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