GNU C++ 3.0 - error in ifstream

Ulrich Breymann breymann@informatik.hs-bremen.de
Mon Jul 16 02:29:00 GMT 2001


Hello,
gcc-bugs@gcc.gnu.org

gcc -v    :
Reading specs from
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/specs
Configured with: ./configure
Thread model: single
gcc version 3.0

Problem:
std::ifstream::open() resp. close() do not clear eof/fail-bits.
Problem arises only if you close the stream and after that try
another open, i.e. reuse the stream

Category: libstd++

Class: sw-bug

Example:

std:ifstream Q;
Q.open("filename");
// .. use Q
Q.close()

// Q.clear();   // this is the Workaround
// reuse of Q
Q.open("another_filename");
if(!Q)  // always, if workaround above is not used, otherwise ok
  std::cerr << "cannot open..." << std::endl;

Work-around:
use clear() before second open() on the same ifstream-object.


regards

Uli Breymann




More information about the Gcc-bugs mailing list