Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 28 Apr 2014 14:22:44 +0200
From: Jens Gustedt <>
Subject: Re: [PATCH 3/3] stddef: Define max_align_t

Am Montag, den 28.04.2014, 12:11 +0200 schrieb Szabolcs Nagy:
> i think i386 abi is non-conforming to the c11 alignment requirements now:
> long long has 8 byte alignment, but in a struct/union it has only 4
> (this is why the attrs are needed above)
> 	long long x; // _Alignof(x) == 8
> 	struct {long long x;} y; // _Alignof(y.x) == 4

I don't think that it is non-conforming

_Alignof of a type only tells you on what alignments the programmer
may place objects of the corresponding type (if he deals with this
manually) and gives no guarantee what the implementation itself choses
under all circumstances

this holds especially if a type has "extended alignment", I think

> i think the standard requires that all (addressable) long long objects
> should have the same alignment (or stricter) than _Alignof(x)
> max_align_t is defined to be the "greatest alignment supported in all
> contexts", i don't know why it is not just

This only concerns "fundamental alignments". Also, this sentence has
an implicit "minimum" operator that comes from the "in all contexts"

if the alignment restriction is 8 in some context and 4 in others, the
result is 4 and not 8.

Perhaps all of this can be made consistent on i386 by having
_Alignof(max_align_t) to be 4 and declare 8 byte and 16 byte aligned
types as having "extended alignment"

I am not sure that I remember correctly, but it seems to me that i386
allows for 4 byte alignment of all types, only that this results in
suboptimal code

> 	typedef char max_align_t __attribute__((aligned(__BIGGEST_ALIGNMENT__)));
> which gives 16 byte alignment on i386 gcc, i thought it was supported
> in all contexts

I think this just not necessary and even counter productive.

> if gcc and clang went with the same definition we should follow, but
> this makes the type less meaningful

By looking at the page that you linked to, my impression is that they
got it wrong. I think basically

typedef union max_align_t max_align_t;

union max_align_t {
  long double a;
  uintmax_t b;
  void* c;
  max_align_t* d;

should do the trick. All other alignments should be considered as
extended alignments.


:: INRIA Nancy Grand Est ::   ::
:: AlGorille ::::::::::::::: office Nancy : +33 383593090   ::
:: ICube :::::::::::::: office Strasbourg : +33 368854536   ::
:: ::::::::::::::::::::::::::: gsm France : +33 651400183   ::
:: :::::::::::::::::::: gsm international : +49 15737185122 ::

Download attachment "signature.asc" of type "application/pgp-signature" (199 bytes)

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.