Unfortunately, it looks like even the very limited functionality of aligned vs template (see, e.g., c++/17743) is broken and I cannot even attempt implementing tr1::type_traits::aligned_storage: the attribute seems completely ignored, otherwise I could at least provide specializations for Align = 1,2,4,8,16... Needless to say, Icc seems ok :( Testcase (but, in case please test partial specializations too!): ////////////// struct A { typedef char type[4] __attribute__((aligned(4))); }; template<unsigned _Len> struct B { typedef char type[_Len] __attribute__((aligned(4))); }; template<bool> struct StaticAssert; template<> struct StaticAssert<true> {}; StaticAssert<__alignof__(A::type) == __alignof__(B<4>::type)> a1; StaticAssert<__alignof__(B<4>::type) == 4> a2; ///////////////// Giovanni can you please have a look?!? Thanks!
We lose the alignment while tsubsting. This is a quick patch for this, I'm not sure if there are other information we should propagate from the original array type to the new array type, I guess the reviewer will know. Meanwhile, Paolo, mind if I ask you to test this patch for me? You can also test the partial specialization, it looks like it works for me.
Created attachment 7828 [details] Untested patch Here is the patch
> Meanwhile, Paolo, mind if I ask you to test this patch for me? You can also > test the partial specialization, it looks like it works for me. Sure, I will: expect some feedback from me before the end of the day! Thank you very much for the quick help!!
Hi again! Yes, I can confirm that the patch works fine here: regtests ok and both the above testcase and the below pass with it, which basically amounts to making possible a decent implementation of tr1::type_traits::aligned_storage Thanks Giovanni! Please post your complete work ASAP and let's have this fixed for 4.0 too, if possible! ////////////////// struct A { typedef char type[4] __attribute__((aligned(4))); }; template<unsigned, unsigned> struct B; template<unsigned _Len> struct B<_Len, 4> { typedef char type[_Len] __attribute__((aligned(4))); }; template<bool> struct StaticAssert; template<> struct StaticAssert<true> {}; StaticAssert<__alignof__(A::type) == __alignof__(B<4, 4>::type)> a1; StaticAssert<__alignof__(B<4, 4>::type) == 4> a2; //////////////////
... forgot to specify: regtested on x86_64-linux.
Patch posted: http://gcc.gnu.org/ml/gcc-patches/2004-12/msg01975.html
Subject: Re: New: __attribute__((aligned)) not working in template "pcarlini at suse dot de" <gcc-bugzilla@gcc.gnu.org> writes: | Unfortunately, it looks like even the very limited functionality of aligned vs | template (see, e.g., c++/17743) is broken and I cannot even attempt implementing | tr1::type_traits::aligned_storage: the attribute seems completely ignored, | otherwise I could at least provide specializations for Align = 1,2,4,8,16... Did I already open a PR for this misbehaviour in the past? What happened? -- Gaby
> Did I already open a PR for this misbehaviour in the past? What > happened? Yes, Gaby, the issue at large is clear, by now: see c++/17743. Here, we are just trying to achieve *minimal* functionality, when the espression in the attribute is not dependent: among other things (currently __align__ inside templates is *totally* broken :( this would allow me to provide a decent first implementation of aligned_storage via specializations for Align=1,2,4,8,16 There is an updated patch ready, which seems to me rather safe http://gcc.gnu.org/ml/gcc-patches/2004-12/msg02003.html Paolo.
The patch was rejected. Not working on this anymore.
Vague references: http://gcc.gnu.org/ml/gcc-patches/2005-10/msg00247.html http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17743 Seems like Mark and/or Nathan have/had state on this that they haven't shared with the lists.
Subject: Re: __attribute__((aligned)) not working in template jason at gcc dot gnu dot org wrote: > ------- Comment #10 from jason at gcc dot gnu dot org 2007-09-06 05:50 ------- > Vague references: > > http://gcc.gnu.org/ml/gcc-patches/2005-10/msg00247.html > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17743 > > Seems like Mark and/or Nathan have/had state on this that they haven't shared > with the lists. I don't think so, but I'm not quite sure I understand. Anyhow, I'm sure I don't have any uncontributed patches for this, and I don't think Nathan has either.
Subject: Re: __attribute__((aligned)) not working in template mark at codesourcery dot com wrote: > I don't think so, but I'm not quite sure I understand. Anyhow, I'm sure > I don't have any uncontributed patches for this, and I don't think > Nathan has either. I do not. I remember looking at it, but didn't get anywhere. nathan
Yo! Jason, fixing this would be most appreciated by the library hackers. This is one of those things that I would really like to see implemented before C++0x gets too far down the road... there is a bunch of stuff depending on this, from both C++0x and TR1. Also, I believe that the deprecated attribute issue is also related to some of these issues. Those bugzilla numbas are: 15269 16370 best, benjamin
Fixed for 4.3.0.