Compiling: template <typename T> using V = __attribute__ ((__vector_size (8))) T; with GCC leads to: tt.C:1:69: warning: ignoring attributes applied to dependent type ‘T’ without an associated declaration [-Wattributes] template <typename T> using V = __attribute__ ((__vector_size (8))) T; ^ while clang produces type V which is vector of integers. This is used by templates in Skia library which I am not sure how to write w/o this construct: // These are __m256 and __m256i, but friendlier and strongly-typed. template <typename T> using V = T __attribute__((ext_vector_type(8))); using F = V<float >; using I32 = V< int32_t>; using U64 = V<uint64_t>; using U32 = V<uint32_t>; using U16 = V<uint16_t>; using U8 = V<uint8_t >; I am not sure how to do the same in a way compatible with GCC.
Applying the attribute to V rather than T works: template <typename T> using V __attribute__ ((__vector_size (8))) = T;
> Applying the attribute to V rather than T works: > > template <typename T> > using V __attribute__ ((__vector_size (8))) = T; Very cool, I did managed to work that out. Should it work the clang way too?
The grammar implies the original form of the alias-declaration should be accepted with standard C++ attributes so I think it would make sense to accept it with GNU attributes as well: alias-declaration: using identifier attribute-specifier-seq opt = defining-type-id; defining-type-id: defining-type-specifier-seq abstract-declarator opt defining-type-specifier-seq: defining-type-specifier attribute-specifier-seq opt defining-type-specifier defining-type-specifier-seq With that, I would expect the following two declarations to be equivalent: template <class T> using U = __attribute__ ((__vector_size__ (8))) T; template <class T> using V = [[gnu::vector_size (8)]] T; Here GCC rejects both forms while Clang accepts the GNU form but (ironically) rejects the standard form.