
Fredrik Blomqvist wrote:
The switch-case in class archive_exception lacks a 'break' after the 'stream> error' case which leads to incorrect what() message.
OK
I also note that the error code "invalid_class_name" doesn't have a message equivalent.
OK
Furthermore I'm confused about this (which was the reason I found the other bug) : (VC7.1 + Dinkumware)
int main() { try { // save { std::ofstream ofs("serializer_test.txt"); boost::archive::text_oarchive oa(ofs);
oa << 'x'; // ofs.close(); // uncommenting this throws "stream_error" (altough currently with wrong what() message) oa << 'y'; }
// load { std::ifstream ifs("serializer_test.txt", std::ios::binary); boost::archive::text_iarchive ia(ifs);
char x, y; ia >> x; // ifs.close(); // uncommenting this _doesn't_ throw? ia >> y;
assert(x == 'x' && y == 'y'); } } catch(std::exception const& e) { std::cout << e.what(); }
return 0; }
Shouldn't reading throw also? The archives check is/os.good() to throw. Or is this a bug in my std.lib (or my understanding of it? ;)
#1 looks correct to me. An attempt to read a closed stream should be an error. #2 looks to me like it should throw as well. One think, I'm checking os.good BEFORE trying to write. I don't check it afterwards. Maybe that's the issue. The reason I did this is that after reading eof - os.good() returns false - not really what we want. But at the point where we can check, we don't know that there isn't anything more to be read. Robert Ramey