Bugzilla will be upgraded to version 5.0 on December 2, 2018. The outage period for the upgrade will start at 0:00 UTC and have a duration of 12 hours
Bug 57126 - ifstream with openmode ios::ate creates empty file
ifstream with openmode ios::ate creates empty file
Product: Red Hat Linux
Classification: Retired
Component: libstdc++ (Show other bugs)
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2001-12-05 09:37 EST by Michael Schwendt
Modified: 2008-05-01 11:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-12-15 13:44:07 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Michael Schwendt 2001-12-05 09:37:03 EST
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):

How reproducible:

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 17:20:07 EDT
Reproducible on Skipjack beta2 with libstdc++-2.96-110.
Comment 2 Alan Cox 2002-12-15 13:44:07 EST
Confirmed working ok in 8.0

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