Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 8 May 2014 12:57:22 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Cc: Pawel Dziepak <pdziepak@...rnos.org>
Subject: Re: [PATCH] add definition of max_align_t to stddef.h

* Rich Felker <dalias@...c.org> [2014-05-07 19:07:29 -0400]:
> BTW, is __alignof__(long double) really giving 8? If so that's utter
> nonsense. sizeof(long double) is 12, and alignment must always divide
> the size of the type...

no, long long is 8 though

#include <stdio.h>
#define p(x) printf("%s == %d\n", #x, (int)(x))
int main()
{
        p(__alignof__(long long));
        p(__alignof__(long double));
        p(__alignof__(union{long long a; long double b;}));
        p(_Alignof(long long));
        p(_Alignof(long double));
        p(_Alignof(union{long long a; long double b;}));
}

gcc 4.8 on i386:
__alignof__(long long) == 8
__alignof__(long double) == 4
__alignof__(union{long long a; long double b;}) == 4
_Alignof(long long) == 8
_Alignof(long double) == 4
_Alignof(union{long long a; long double b;}) == 4

gcc 4.9 on i386:
__alignof__(long long) == 8
__alignof__(long double) == 4
__alignof__(union{long long a; long double b;}) == 4
_Alignof(long long) == 4
_Alignof(long double) == 4
_Alignof(union{long long a; long double b;}) == 4

gcc 4.9 on arm:
__alignof__(long long) == 8
__alignof__(long double) == 8
__alignof__(union{long long a; long double b;}) == 8
_Alignof(long long) == 8
_Alignof(long double) == 8
_Alignof(union{long long a; long double b;}) == 8


> As I see it, we have a choice whether to use the "8" definition on
> i386 or use the natural definition, which would yield "4" on i386.
> This is not an ABI issue (it does not affect the ability to use
> glibc-built object files/binaries/shared libraries with musl, nor the
> C++ name mangling ABI) but an API issue.

assuming max_align_t does not appear in a function prototype

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.