libc++ patch for max_align_t

Richard Smith richard at metafoo.co.uk
Sat Feb 15 23:13:40 PST 2014


This seems to be going in the wrong direction.

* max_align_t needs to be in <stddef.h> as well as in <cstddef>
* <stddef.h> is provided by the compiler, not by the standard library
* max_align_t is de facto part of the platform's ABI. It's not enough to
get the alignment right, you also need to get the size and mangled name of
the type right (and possibly other things too).

IMO, the right thing to do here is to add a definition to max_align_t to
Clang's lib/Headers/stddef.h, and add a using declaration to libc++'s
cstddef to pull it into namespace std.


On Mon, Feb 10, 2014 at 1:16 PM, Howard Hinnant <howard.hinnant at gmail.com>wrote:

> On Feb 10, 2014, at 2:25 PM, Howard Hinnant <howard.hinnant at gmail.com>
> wrote:
>
> >> It seems like the old behavior follows the standard more closely. If Len
> >> == 17, then _any_ c++ object with size no greater than Len includes
> >> objects of size 16 and some objects of size 16 maybe have an alignment
> >> requirement of 16.
> >
> > Ok, I'm convinced, thanks.
>
> I've enclosed a slightly updated patch.  I've added float as Kal
> suggested, but haven't added uintmax_t because of not wanting to couple
> <cstddef> to <cstddint>.  I have not modified the behavior, thanks to Kal.
>
> std::__find_max_align<std::__all_types, 1>::value = 1
> std::__find_max_align<std::__all_types, 2>::value = 2
> std::__find_max_align<std::__all_types, 3>::value = 2
> std::__find_max_align<std::__all_types, 4>::value = 4
> std::__find_max_align<std::__all_types, 5>::value = 4
> std::__find_max_align<std::__all_types, 6>::value = 4
> std::__find_max_align<std::__all_types, 7>::value = 4
> std::__find_max_align<std::__all_types, 8>::value = 8
> std::__find_max_align<std::__all_types, 9>::value = 8
> std::__find_max_align<std::__all_types, 10>::value = 8
> std::__find_max_align<std::__all_types, 11>::value = 8
> std::__find_max_align<std::__all_types, 12>::value = 8
> std::__find_max_align<std::__all_types, 13>::value = 8
> std::__find_max_align<std::__all_types, 14>::value = 8
> std::__find_max_align<std::__all_types, 15>::value = 8
> std::__find_max_align<std::__all_types, 16>::value = 16
> std::__find_max_align<std::__all_types, 17>::value = 16
> std::__find_max_align<std::__all_types, 18>::value = 16
> std::__find_max_align<std::__all_types, 19>::value = 16
> std::__find_max_align<std::__all_types, 20>::value = 16
> std::__find_max_align<std::__all_types, 21>::value = 16
> std::__find_max_align<std::__all_types, 22>::value = 16
> std::__find_max_align<std::__all_types, 23>::value = 16
> std::__find_max_align<std::__all_types, 24>::value = 16
> std::__find_max_align<std::__all_types, 25>::value = 16
> std::__find_max_align<std::__all_types, 26>::value = 16
> std::__find_max_align<std::__all_types, 27>::value = 16
> std::__find_max_align<std::__all_types, 28>::value = 16
> std::__find_max_align<std::__all_types, 29>::value = 16
> std::__find_max_align<std::__all_types, 30>::value = 16
> std::__find_max_align<std::__all_types, 31>::value = 16
> std::__find_max_align<std::__all_types, 32>::value = 16
> std::__find_max_align<std::__all_types, 33>::value = 16
> ...
>
> Howard
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140215/871bddff/attachment.html>


More information about the cfe-commits mailing list