【发布时间】:2015-07-25 20:59:05
【问题描述】:
这是一个 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 支持继承构造函数is new with that version。
我已经为此提交了一份错误报告,因为至少编译器不应该崩溃。但是,我可以确认这是正确的 C++ 用法/解决方法吗?
错误报告here
【问题讨论】:
-
@DavidHaim:这是一个继承构造函数声明。
-
您对MSCV还有什么期望?解决方法:改用合适的编译器,例如 clang。
-
什么是“MSCV”,@Walter?
-
这不是一个程序,您可以通过省略不必要的
publics 来提高代码的可读性:coliru.stacked-crooked.com/a/164072087e303251 更进一步,我实际上建议将其稍长一些但间距更好:@ 987654324@ 只是一个想法。 -
@imallett 我认为您的连接错误报告需要更多详细信息。您至少应该提供错误消息(就像您在这里一样),而不仅仅是 smartass cmets。
标签: c++ c++11 visual-c++ visual-studio-2015 internal-compiler-error