Bug 117008 - libstdc++ 3.2.3 does not support opening files > 2GB
Summary: libstdc++ 3.2.3 does not support opening files > 2GB
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: gcc3
Version: 3.0
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2004-02-27 11:50 UTC by Michael Doppler
Modified: 2007-11-30 22:07 UTC (History)
1 user (show)

Clone Of:
Last Closed: 2004-05-27 15:01:27 UTC

Attachments (Terms of Use)

Description Michael Doppler 2004-02-27 11:50:24 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6)
Gecko/20040206 Firefox/0.8

Description of problem:
The STL filestreams (std::[io]fstream) supplied with the libstdc++
3.2.3 rpm on RedHat Enterprise Linux 3 seem to lack support for
opening files that are bigger than 2 GB.

The following test program deomonstrates this issue.

It opens a 2500MB file, once using std::ifstream::open() and another
time using the C library open() system call.

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <iostream>
#include <fstream>

int main()
    std::ifstream test( "2500MB.bin" );
    if( !test.is_open() )
        std::cout << "Open via ifstream::open() failed!" << std::endl;

    if( ::open( "2500MB.bin", O_RDONLY ) == -1 )
        std::cout << "Open via C open() failed!" << std::endl;

    return 0;

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

How reproducible:

Steps to Reproduce:
1. Compile test program: g++ -D_FILE_OFFSET_BITS=64
2. Create a file > 2GB: dd if=/dev/zero of=2500MB.bin bs=1M count=2500
on an ext3 partition
3. Call the testprogram in the directory the file was created: ./a.out

Actual Results:  std::ifstream::open() fails, C lib open() succeeds.

Expected Results:  Both open() calls succeed.

Additional info:

Curiously, when using std::ifstream::open() on the 2500MB file on a
reiserfs partition it succeeds. I don't know if this is a Bug or a
feature of that filesystem. 

Note that the C open() also succeeds when adding the O_LARGEFILE flag
and compiling the test program without the defines.

Comment 1 Suzanne Hillman 2004-03-02 21:48:54 UTC
Internal RFE bug #117336 entered.

Comment 2 Jakub Jelinek 2004-05-27 15:01:27 UTC
This will be fixed in RHEL4.  It is not suitable for RHEL3, as it
needs to maintain libstdc++ ABI compatibility.

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