This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/7235: iostream bug: cannot re-read a file.
- From: Andrea Latina <latina at to427xl dot to dot infn dot it>
- To: gcc-gnats at gcc dot gnu dot org
- Date: Mon, 8 Jul 2002 19:55:10 +0200
- Subject: c++/7235: iostream bug: cannot re-read a file.
>Number: 7235
>Category: c++
>Synopsis: If I open twice a file, I'm not able to read anything from it.
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jul 08 10:46:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Andrea Latina
>Release: 3.1
>Organization:
>Environment:
System: Linux to427xl.to.infn.it 2.4.18-5smp #1 SMP Mon Jun 10 15:19:40 EDT 2002 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.1/configure --enable-threads
>Description:
When I close a file previously opened, then I reopen it, I'm not able to read anything from the file.
>How-To-Repeat:
I report the code exploiting the error:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream file("dati");
if (file)
{
int x, y;
while(file >> x >> y) cout << x << '\t' << y << endl;
file.close();
file.open("dati");
// the following line fails!
while(file >> x >> y) cout << x << '\t' << y << endl;
}
return 0;
}
where "dati" is a ascii file, like this:
10 10
20 20
for example.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: