This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/12409] cannot reuse ofstream due to interaction between <string> and <fstream>
- From: "kouptsov at wsu dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Sep 2003 00:16:29 -0000
- Subject: [Bug libstdc++/12409] cannot reuse ofstream due to interaction between <string> and <fstream>
- References: <20030925184151.12409.kouptsov@wsu.edu>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12409
------- Additional Comments From kouptsov at wsu dot edu 2003-09-26 00:16 -------
There are actually two bugs related to <fstream>:
1. The file is opened but os.is_open() gives 'false':
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string filename;
ofstream os;
filename = "data-0";
os.open(filename.c_str());
for(int i=-5; i<5; i++) os<<i<<" "<<endl;
os.close();
filename = "data-1";
os.open(filename.c_str());
if(os.is_open()) {cerr<<"file '"<<filename<<"' not opened"<<endl;} /* exit(-1)
removed */
for(int i=-5; i<5; i++) os<<i<<" "<<endl;
os.close();
return 0;
}
$ make
g++ -c -o openfile-2.o openfile-2.cpp
g++ -Wall -lm -o run openfile-2.o
$ run
file 'data-1' not opened
$ ls -l data-*
-rw-r--r-- 1 klk206 users 35 Sep 25 17:12 data-0
-rw-r--r-- 1 klk206 users 35 Sep 25 17:12 data-1
The file data-1 was opened and data written.
2. Reported in #12412.