fstream fails to create a file in ios::in| ios::out mode. gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-34) environment: 2.4.21-20.ELsmp i686 GNU/Linux
Sample Code: -------------------------------------------- #include <errno.h> #include <fstream> #include <iostream> using namespace::std; int main() { fstream f("test", ios::in|ios::out); if(!f.is_open()) { cout<<"could not open test: "<<strerror(errno)<<endl; return 1; } else { cout<<"opened test"<<endl; f.seekp(0, ios::end); f<<"This is a test"<<endl; f.seekg(ios::beg); string st; while(f>>st) cout<<st<<endl; } return 0; } -------------------------------------------- output: if file doesn't exist -------------------------------------------- could not open test: No such file or directory -------------------------------------------- output: if file is created using touch command -------------------------------------------- opened test This is a test -------------------------------------------- -- Summary: fstream fails to create a file in ios::in| ios::out mode. Product: gcc Version: 3.2.3 Status: UNCONFIRMED Severity: critical Priority: P1 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rohit_goel at ml dot com CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22130