C++: istream.eof on gcc 4.6
Hugo Arregui
hugo.arregui@gmail.com
Fri Apr 22 02:50:00 GMT 2011
Hi guys,
today I find a change on istream.eof when I upgrade from 4.5.2 to 4.6.0.
Here's a little example showing the change, this code will show "true,
true" using gcc 4.5.2 (and previous), and "true, false" using 4.6:
I don't know if it's a bug, or some expected change, or even if i'm
wrong blaming gcc. Can you confirm that?
-----
The code:
#include <iostream>
#include <sstream>
using namespace std;
static bool is_next_char_readable(istream& file)
{
file.get();
const bool result = file.eof();
file.unget();
return result;
}
int main()
{
istringstream s("test");
s.seekg(0, ios_base::end);
std::cout << is_next_char_readable(s) << std::endl;
std::cout << is_next_char_readable(s) << std::endl;
return 0;
}
More information about the Gcc-help
mailing list