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: max_align_t definition


On Thu, Apr 09, 2015 at 02:36:01PM +0200, Florian Weimer wrote:
> On 04/09/2015 02:31 PM, Joseph Myers wrote:
> 
> > It's C90 DR#075 that requires malloc (1) to return a pointer suitably 
> > aligned for all types (including long double).  (That is, all types that 
> > can be defined using C90 standard syntax.)
> > 
> >> Before C11, this was perfectly conforming.  I doubt it was the intention
> > 
> > No, it was never conforming for malloc (1) to return memory not aligned 
> > for long double.
> 
> Why is that so?  Is the argument that the result of malloc (1) could be
> used to store a zero-length array of arbitrarily large objects (such as
> long double, whose size is almost certainly larger than 1)?

Don't know the reasons, but e.g. from the optimizers side, it is surely nice
if there is some alignment requirement on the returned value regardless of
the size.  Because otherwise you could optimize only if the malloc argument
was constant or compiler analysis could prove it is bigger or equal to some
minimum value.

	Jakub


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