The following C++ code gets a mysterious error ("Debug Error!...abort() has been called") when the return
is executed. This is Visual Studio 2017 15.6.3, and the program is a 64-bit debug build, running under 64-bit Windows 7. What is causing this error, and how can I fix it?
wifstream inFile;
std::codecvt_utf16<wchar_t, 0x10ffff, std::little_endian> cv1;
inFile.imbue(std::locale(inFile.getloc(), &cv1));
return 0;
Tracing through with the debugger shows the message is coming from the disassembler instruction
call std::basic_ifstream<wchar_t,std::char_traits<wchar_t> >::`vbase destructor'
The last entry on the stack, other than msvcp140d.dll
, vcruntime140d.dll
and ucrtbased.dll
is
MyApp.exe!std::basic_ifstream<wchar_t,std::char_traits<wchar_t> >::`vbase destructor'() C++
The purpose of this code is the input file infile
is Unicode (little-endian), and I am reading it into a std::string
variable.