我想我可能在VS2013附带的MSVC++编译器中发现了一个编译器错误,但这是一个我不能确定的简单情况。再加上我仍在学习C++的事实,我想在提交任何内容之前先在这里提问;因为老实说,我很确定这只是我做错了事导致了一个不寻常的错误信息。这是一个MSVC++编译器错误?
反正我在一个小测试文件,减少了问题:
#include <string>
#include <iostream>
std::wstring cstr_to_wstring(const char* cString) {
std::string temp = cString;
return { temp.begin(), temp.end() };
}
int main() {
std::cout << cstr_to_wstring("Hi").c_str();
}
当我尝试编译,我得到以下错误:
1>d:\documents\projects\compilerbugtest\compilerbugtest\compilerbugtest.cpp(6): fatal error C1001: An internal error has occurred in the compiler.
1> (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 227)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
要解决的问题,我只需指定六个线类型,因此:
return { temp.begin(), temp.end() };
变成
return std::wstring { temp.begin(), temp.end() };
。
这真的是一个编译器错误吗?谢谢。
我会说'编译器内部错误总是值得报告,无论使用的源代码。 – GSerg
当编译器指出这是一个编译器错误时,那么它就是编译器中的一个错误,或者说它是编译器中的一个错误。在这两种情况下,这是一个编译器错误:-) –
哈哈,好点,GSerg和Torsten ... :) – Xenoprimate