What does this warning mean?
Here is the mcve.
template<class K> class TTT{
public: alignas(alignof(K))
union{
char raw[sizeof(K)];
K rawK;
}; //<-- error at this line
};
If I compile this single file with ctrl+F7
in Visual Studio 2015, I will get this warning.
warning C4649: attributes are ignored in this context
note: see reference to class template instantiation 'TTT<K>' being compiled
I appear in my computer, but http://rextester.com can't reproduce this warning though.
Other information :-
TTT<K>
is never really instantiated.alignas(alignof(K))
, the warning will disappear. I can't really find any sites that has some useful description about it.
Has anyone ever encountered it before?
Reading e.g. this alignas
reference it should be placed between the struct
or union
keyword and the structure/union tag.
So it should be something like
template<class K> struct TTT{
union alignas(alignof(K)) {
// ^^^^^^^^^^^^^^^^^^^
// Note placement
char raw[sizeof(K)];
K rawK;
};
};