This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] [PR19163] Fix attribute aligned on dependent arraytypes


Paolo Carlini wrote:

In the meanwhile, for 4.0, as far as tr1::type_traits::aligned_storage is concerned, probably I can devise a work-around, as per the implementation note 4.8, thus using __alignof__...

Like this, roughly, but probably I will not be able to finalize the 4.0 version of
alignment_of and aligned_storage before next week (a few days off, finally... ;)


template<std::size_t, std::size_t>
 struct aligned_storage;

template<std::size_t _Len>
 struct aligned_storage<_Len, 1>
 {
   union type
   {
     unsigned char __data[_Len];
     char __align __attribute__((aligned(1)));
   };
 };

template<std::size_t _Len>
 struct aligned_storage<_Len, 2>
 {
   union type
   {
     unsigned char __data[_Len];
     char __align __attribute__((aligned(2)));
   };
 };

template<std::size_t _Len>
 struct aligned_storage<_Len, 4>
 {
   union type
   {
     unsigned char __data[_Len];
     char __align __attribute__((aligned(4)));
   };
 };

template<std::size_t _Len>
 struct aligned_storage<_Len, 8>
 {
   union type
   {
     unsigned char __data[_Len];
     char __align __attribute__((aligned(8)));
   };
 };

template<std::size_t _Len>
 struct aligned_storage<_Len, 16>
 {
   union type
   {
     unsigned char __data[_Len];
     char __align __attribute__((aligned(16)));
   };
 };

template<std::size_t _Len>
 struct aligned_storage<_Len, 32>
 {
   union type
   {
     unsigned char __data[_Len];
     char __align __attribute__((aligned(32)));
   };
 };

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]