* Template aliases and attributes
@ 2019-11-29 15:34 Martin Reinecke
2019-11-29 15:44 ` Alexander Monakov
0 siblings, 1 reply; 3+ messages in thread
From: Martin Reinecke @ 2019-11-29 15:34 UTC (permalink / raw)
To: gcc-help
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?
Thanks in advance,
Martin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Template aliases and attributes
2019-11-29 15:34 Template aliases and attributes Martin Reinecke
@ 2019-11-29 15:44 ` Alexander Monakov
2019-11-29 15:47 ` Martin Reinecke
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Monakov @ 2019-11-29 15:44 UTC (permalink / raw)
To: Martin Reinecke; +Cc: gcc-help
[-- Attachment #1: Type: text/plain, Size: 970 bytes --]
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Template aliases and attributes
2019-11-29 15:44 ` Alexander Monakov
@ 2019-11-29 15:47 ` Martin Reinecke
0 siblings, 0 replies; 3+ messages in thread
From: Martin Reinecke @ 2019-11-29 15:47 UTC (permalink / raw)
To: Alexander Monakov; +Cc: gcc-help
On 11/29/19 4:44 PM, Alexander Monakov wrote:
> 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.
Oh, I see! Thank you very much for the explanation!
Cheers,
Martin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-11-29 15:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-29 15:34 Template aliases and attributes Martin Reinecke
2019-11-29 15:44 ` Alexander Monakov
2019-11-29 15:47 ` Martin Reinecke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).