Bug 57126 - ifstream with openmode ios::ate creates empty file
Summary: ifstream with openmode ios::ate creates empty file
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: libstdc++
Version: 7.2
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-12-05 14:37 UTC by Michael Schwendt
Modified: 2008-05-01 15:38 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2002-12-15 18:44:07 UTC
Embargoed:


Attachments (Terms of Use)

Description Michael Schwendt 2001-12-05 14:37:03 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.6) Gecko/20011120

Description of problem:
Creating an ifstream (or fstream with ios::in) object with openmode
ios::ate and with the name of a non-existant file creates an empty file on
the filesystem.

// testprogram.cpp

#include <fstream>
using namespace std;

int main(int,char**)
{
    fstream fTest( "testfile", ios::in|ios::ate );
    return 0;
}


Version-Release number of selected component (if applicable):
2.96-98


How reproducible:
Always

Steps to Reproduce:
1. # g++ testprogram.cpp -o testprogram
2. # rm -f testfile ; ./testprogram
3. # file testprogram


Actual Results:  $ file testfile
testfile: empty


Expected Results:  $ file testfile
testfile: can't stat `testfile' (No such file or directory).


Additional info:

ios::nocreate has not made it into the C++ Standard. Creating an input
fstream object upon a non-existant file should fail without creating an
empty file.

Comment 1 Michael Schwendt 2002-04-26 21:20:07 UTC
Reproducible on Skipjack beta2 with libstdc++-2.96-110.

Comment 2 Alan Cox 2002-12-15 18:44:07 UTC
Confirmed working ok in 8.0



Note You need to log in before you can comment on or make changes to this bug.