I'm getting a failure on Linux when calling the read()
function on basic_fstream<unsigned char>
stream:
basic_fstream<unsigned char> fs;
basic_string<unsigned char> buf(1000, '\0');
fs.open( "/tmp/file.txt", ios::in | ios::binary);
fs.read( &buf[0], 1000);
I traced where it throws: in function __check_facet(const _Facet* __f)
it throws __throw_bad_cast()
because __f
is NULL. The __check_facet()
in turn is called from underflow()
, with _M_codecvt
as the parameter (which is NULL and causes the failure).
The system's locale is UTF8, the code is compiled with --std=c++14. On Windows this works OK.
Can it be corrected somehow?