This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
New problem with fstreams?!?
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: libstdc++ at gcc dot gnu dot org
- Cc: bkoz at redhat dot com, CGLeggett at lbl dot gov
- Date: Sat, 26 Jan 2002 13:04:29 +0100
- Subject: New problem with fstreams?!?
Hi all, hi Benjamin,
my friend Charles Leggett brought to my attention a recent problem with
fstreams. This a reduced
testcase:
//////////
#include <iostream>
#include <fstream>
std::fstream scratch_file;
int main()
{
scratch_file.open("SCRATCH", std::ios::out);
scratch_file << " just stuff " << "\n";
scratch_file.close();
for (int i=0; i<10; ++i)
{
std::cout << i << "\n";
scratch_file.open("SCRATCH", std::ios::in);
if(!scratch_file) {
std::cerr << "Cannot open SCRATCH\n";
abort();
}
scratch_file.close();
}
}
//////////
Currently, this is the output:
0
1
Cannot open SCRATCH
Abort
On the other hand, if I revert this patch:
2002-01-08 Benjamin Kosnik <bkoz@redhat.com>
libstdc++/2913
libstdc++/4879
* include/bits/fstream.tcc (filebuf::_M_really_overflow): Test
return value of _M_file->sync().
(filebuf::showmanyc): Check for is_open.
* include/std/fstream (filebuf::sync): Tweak.
the behavior is completely different (the same delivered by 3.0.3):
0
1
2
3
4
5
6
7
8
9
Does this trigger you something?
Cheers,
Paolo.