Re: Template aliases and attributes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 29 Nov 2019, Martin Reinecke wrote:

> Hi,
> 
> g++ is unhappy about the statement:
> 
> template<typename T, int len> using vtype = T __attribute__
> ((vector_size (len*sizeof(T))));
> 
> and reports:
> 
> vectest.cc:1:91: warning: ignoring attributes applied to dependent type
> ‘T’ without an associated declaration [-Wattributes]
>     1 |  using vtype = T __attribute__ ((vector_size (len*sizeof(T))));
>       |                                                              ^
> 
> clang++ on the other hand seems to be OK with this.
> 
> Is there some subtlety I'm missing?
> If so, is there analternative way to express what I have in mind?

gcc expects the attribute on the type being declared, not the base type,
so you need to place the attribute on vtype:

template<typename T, int len>
using vtype __attribute__ ((vector_size (len*sizeof(T)))) = T;

This matches how [[attributes]] are meant to be placed in C++11 alias templates.

Alexander

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux