This is the mail archive of the
mailing list for the GCC project.
Re: x86_64: Should the -mavx* options affected __alignof__ (max_align_t)?
- From: Andrew Haley <aph at redhat dot com>
- To: Florian Weimer <fweimer at redhat dot com>, Joseph Myers <joseph at codesourcery dot com>
- Cc: GCC <gcc at gcc dot gnu dot org>
- Date: Thu, 02 Apr 2015 09:40:00 +0100
- Subject: Re: x86_64: Should the -mavx* options affected __alignof__ (max_align_t)?
- 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>
On 04/02/2015 09:26 AM, Florian Weimer wrote:
> On 03/23/2015 07:41 PM, Florian Weimer wrote:
>> Ah, I should have looked at what max_align_t actually meant. With these
>> semantics, the name is a bit confusing. I agree that requiring 64 byte
>> alignment from malloc does not make much sense. Thanks.
> Follow-up question: Can malloc return a pointer which is not aligned to
> _Alignof (max_align_t)?
max_align_t is specified in 7.19#2 as "an object type...
As for malloc:
"The pointer returned if the allocation succeeds is suitably aligned
so that it may be assigned to a pointer to any type of object with a
fundamental alignment requirement and then used..."
"A fundamental alignment is represented by an alignment less than or
equal to the greatest alignment supported by the implementation in all
contexts, which is equal to _Alignof (max_align_t)."
So, max_align_t is an object type, and therefore malloc returns a
pointer suitable for max_align_t.