|
Message-ID: <CALS3df2W9LuMFV9VUdAu1XY5z5BTre6qUCOJq5AGg+FM3zOidw@mail.gmail.com> Date: Thu, 8 May 2014 22:45:20 +0200 From: Paweł Dziepak <pdziepak@...rnos.org> To: Rich Felker <dalias@...c.org> Cc: musl@...ts.openwall.com Subject: Re: [PATCH] add definition of max_align_t to stddef.h 2014-05-08 22:02 GMT+02:00 Rich Felker <dalias@...c.org>: > On Thu, May 08, 2014 at 09:45:39PM +0200, Paweł Dziepak wrote: >> 6.7.5 doesn't mention such requirement. _Alignas, obviously, cannot >> reduce the alignment requirement and the specified alignment has to >> has to be either a valid fundamental alignment or valid extended >> alignment supported by the implementation. Moreover, 6.2.8 requires >> that valid alignment is a nonnegative integral power of two. As for >> the additional requirement in contract of aligned_alloc 7.22.3.1 >> states that the requested alignment has to be valid and divide size of >> the requested memory block. I don't see how that would disallow using >> in alignas alignment larger than the size of the object. > > The alignment of a type must divide its size; this is fundamental to > the existence of arrays. It's possible that, for an ugly definition of > "alignment of an object" independent of an alignment associated with > the type, some objects could be aligned with more alignment than their > size, but I'm not convinced that the standard intends to allow such > nonsense. My point about aligned_alloc was that its interface > requirements reflect the notion that alignment always divides size. I'm not sure how alignas() could cause problems with arrays. It cannot be used in declarations of typedefs. When applied to structure member or the whole structure (like struct alignas(N) foo { ... }, C++11 alows it) it changes the size of the structure itself so the alignment remains less than or equal size of the object and in declarations like this: alignas(N) T foo[K]; alignas() applies to the array foo, not each individual element of that array. Paweł
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.