This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: max_align_t definition
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: Joseph Myers <joseph at codesourcery dot com>, GCC <gcc at gcc dot gnu dot org>
- Date: Thu, 9 Apr 2015 14:42:23 +0200
- Subject: Re: max_align_t definition
- Authentication-results: sourceware.org; auth=none
- References: <55105B5B dot 50107 at redhat dot com> <alpine dot DEB dot 2 dot 10 dot 1503231831300 dot 14930 at digraph dot polyomino dot org dot uk> <55105E53 dot 8020002 at redhat dot com> <551CFD38 dot 9040200 at redhat dot com> <alpine dot DEB dot 2 dot 10 dot 1504021640470 dot 408 at digraph dot polyomino dot org dot uk> <55264E4A dot 3000905 at redhat dot com> <alpine dot DEB dot 2 dot 10 dot 1504091225570 dot 4346 at digraph dot polyomino dot org dot uk> <55267231 dot 5050700 at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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