这是一段10行的C++11程序,它是从我正在工作中的程序中大量简化而来:
template <typename T> class Base { public:
template <typename S> Base(S x) {}
};
template <typename T> class Child : public Base<T> { public:
using Base<T>::Base;
};
template <> class Child<int> : public Base<int> { public:
using Base<int>::Base;
};
int main()
{
Child<int> child(8.0f);
}
MSVC 2015 输出:
1>------ Build started: Project: MyProject, Configuration: Debug Win32 ------
1> filename.cpp
1>path\to\filename(10): fatal error C1001: An internal error has occurred in the compiler.
1> (compiler file 'msc1.cpp', line 1393)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
1> Please choose the Technical Support command on the Visual C++
1> Help menu, or open the Technical Support help file for more information
注意:MSVC 2015支持继承构造函数是从该版本开始的。
我已经提交了一个错误报告,因为编译器至少不应该崩溃。但是,请确认这是否是正确的C++用法/解决方法?
错误报告在这里