This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: x86_64: Should the -mavx* options affected __alignof__ (max_align_t)?
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: "H.J. Lu" <hjl dot tools at gmail dot com>, Andrew Haley <aph at redhat dot com>, GCC <gcc at gcc dot gnu dot org>
- Date: Thu, 2 Apr 2015 11:34:26 +0000
- 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> <551D0060 dot 1020805 at redhat dot com> <551D01E5 dot 9070405 at redhat dot com> <CAMe9rOoxjp1TFUgg493r_1LT9S9ZH=1D-+riO3f32A_WqcYN3A at mail dot gmail dot com> <551D2319 dot 4010905 at redhat dot com>
On Thu, 2 Apr 2015, Florian Weimer wrote:
> On 04/02/2015 01:06 PM, H.J. Lu wrote:
> > On Thu, Apr 2, 2015 at 1:46 AM, Florian Weimer <fweimer@redhat.com> wrote:
> >> On 04/02/2015 10:40 AM, Andrew Haley wrote:
> >>
> >>> So, max_align_t is an object type, and therefore malloc returns a
> >>> pointer suitable for max_align_t.
> >>
> >> Then the GCC definition of max_align_t is incorrect, it should be 8 on
> >> x86_64 GNU/Linux, because traditionally, that's what mallocs implement
> >> for this architecture. (dlmalloc in glibc is an exception.)
> >>
> >
> > x86-64 psABI specifies that a memory >= 16 bytes is 16-byte aligned.
> > If malloc doesn't do it, it is a broken.
>
> My concern is different. I think _Alignof (max_align_t) == 16 (as it is
> in GCC now) implies that malloc return values for sizes less than 16
> bytes are 16-byte-aligned, too, which is not required by the x86-64 psABI.
Right back to C90 (DR#075), malloc of any size has been required to return
a pointer suitably aligned for all types that can be defined in C90 (such
as long double). ABIs can only be understood in conjunction with the
language standard requirements. If malloc fails to return memory suitably
aligned for long double, that's a malloc bug.
--
Joseph S. Myers
joseph@codesourcery.com