Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 81359 - after fopen(, "a+") ftell() gives 0 not EOF
after fopen(, "a+") ftell() gives 0 not EOF
Product: Red Hat Linux
Classification: Retired
Component: man-pages (Show other bugs)
i386 Linux
low Severity medium
: ---
: ---
Assigned To: Eido Inoue
Ben Levenson
Depends On:
  Show dependency treegraph
Reported: 2003-01-08 10:01 EST by Joe Orton
Modified: 2007-03-26 23:59 EDT (History)
1 user (show)

See Also:
Fixed In Version: 1.60-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2003-08-28 16:31:44 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
repro case for ftell bug (386 bytes, patch)
2003-01-08 10:02 EST, Joe Orton
no flags Details | Diff

  None (edit)
Description Joe Orton 2003-01-08 10:01:51 EST
Description of problem:
Bug report courtesy of PHP CVS: for a non-zero-length file opened with fopen(,
"a+"), ftell(fp) gives 0 not the EOF location.

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

How reproducible:

Steps to Reproduce:
1. gcc ftell.c
2. ./a.out
3. echo $?
Actual results:

Expected results:

Additional info:
Comment 1 Joe Orton 2003-01-08 10:02:54 EST
Created attachment 89212 [details]
repro case for ftell bug
Comment 2 Jakub Jelinek 2003-01-20 13:20:14 EST
See info libc on fopen:
          Open or create file for both reading and appending.  If the
          file exists, its initial contents are unchanged.  Otherwise,
          a new file is created.  The initial file position for reading
          is at the beginning of the file, but output is always
          appended to the end of the file.
Comment 3 Joe Orton 2003-01-21 04:33:09 EST
This is a deliberate change in behaviour since glibc 2.2, then?

The fopen man page says "The stream is positioned at the end of the file", so at
least this is a documentation bug.
Comment 4 Jakub Jelinek 2003-01-21 04:51:31 EST
Yes, it was deliberate change:
2002-08-26  Ulrich Drepper  <drepper@redhat.com>

        * libio/Makefile (tests): Add bug-fopena+.
        * libio/bug-fopena+.c: New file.
        * libio/fileops.c (_IO_file_open): Only set file pointer to end of the
        file for _IO_IS_APPENDING if file isn't opened for reading, too.

This is documented in libc.info, manual pages are hopelessly outdated.
Comment 5 Eido Inoue 2003-08-28 16:31:44 EDT
fixed in 1.60-1

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