This is the mail archive of the gcc@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: __alignof__(T) not compile time constant?


Paolo Carlini wrote:
> Can you imagine a temporary fix for libstdc++/8670? Perhaps that
> suggested at the time by Martin?

In principle this ought to work, although it doesn't seem to (forgive
me if this isn't a good way to write it, it's 6 years since I wrote C++):

template <int a> struct aligned;

struct aligned<1> { template <typename _t> struct t { typedef __attribute__((aligned(1))) _t type; }; };
struct aligned<2> { template <typename _t> struct t { typedef __attribute__((aligned(2))) _t type; }; };
struct aligned<4> { template <typename _t> struct t { typedef __attribute__((aligned(4))) _t type; }; };
struct aligned<8> { template <typename _t> struct t { typedef __attribute__((aligned(8))) _t type; }; };
struct aligned<16> { template <typename _t> struct t { typedef __attribute__((aligned(16))) _t type; }; };

struct foo {
  aligned<__alignof__(long long)>::t<char>::type x;
} bar;

-- Jamie


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