This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: __alignof__(T) not compile time constant?
- From: Jamie Lokier <jamie at shareable dot org>
- To: Paolo Carlini <pcarlini at unitus dot it>
- Cc: Gabriel Dos Reis <gdr at integrable-solutions dot net>, Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>, gcc at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Fri, 3 Oct 2003 07:15:51 +0100
- Subject: Re: __alignof__(T) not compile time constant?
- References: <Pine.LNX.4.44.0309291631060.898-100000@bellatrix.tat.physik.uni-tuebingen.de> <m3brt37i8o.fsf@uniton.integrable-solutions.net> <3F7B4AA5.1050804@unitus.it>
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