The following code compiles well under gcc and clang, but throws the C4700 "uninitialized local variable 'a' used" error in Visual Studio:
template<size_t T>
class V
{
public:
int v[T];
V() = default;
template<typename ...A>
V(A... args):
v{static_cast<T>(args)...}
{}
};
int main()
{
V<2> a(2, 2);
V<2> b = a;
return 0;
}
If I add body to the constructor (by removing the = default and adding {}) the error goes away. I can' t find anything that mandates this behavior in the spec. Is this a bug in Visual C++ compiler or I am missing something in the spec?
Aucun commentaire:
Enregistrer un commentaire