This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
libstdc++-v3 3.4.4: fstream does not create a file on open
- From: Francesco Palagi <palagi at arcetri dot astro dot it>
- To: libstdc++ at gcc dot gnu dot org
- Date: Tue, 05 Jun 2007 11:41:17 +0200
- Subject: libstdc++-v3 3.4.4: fstream does not create a file on open
Hi,
when I try to connect a non existent file to an fstream object calling
the open member function, the file is not created.
Here is a small test program:
#include <fstream>
using namespace std;
int main(int argc, char **argv)
{
char s[81];
fstream f;
f.clear();
f.open("text.txt");
int state = f.rdstate();
printf("%d\n",state);
if(! f.fail()) {
f << "la vita e' bella" << endl;
f.flush();
}
f.close();
return 0;
}
I get state = 4
I think this is not what one would expect.
My system is:
> uname -a
Scientific Linux palagi 2.6.9-42.0.10.ELsmp #1 SMP Tue Feb 27 12:38:15
EST 2007 x86_64 x86_64 x86_64 GNU/Linux
gcc (GCC) 3.4.4 20050721 (Red Hat 3.4.4-2)
libstdc++-v3 3.4.4
Thanks for any suggestion.
Francesco Palagi
--
-------------------------------oOo--------------------------------
Francesco PALAGI | phone: +39 0552752216
INAF - Ist. di Radioastronomia | fax: +39 055220039
Sezione di Firenze |
l.go E. Fermi, 5 | e-mail: palagi@arcetri.inaf.it
I 50142 Firenze (Italy) |
===================================================================