我想我可能在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