Bug 57126

Summary: ifstream with openmode ios::ate creates empty file
Product: [Retired] Red Hat Linux Reporter: Michael Schwendt <bugs.michael>
Component: libstdc++Assignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-12-15 18:44:07 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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