From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 Firebird/0.7 Description of problem: Code that needs to write a large file (greater then 2048) fails. Version-Release number of selected component (if applicable): gcc-c++-2.96-113 gcc-2.96-113 How reproducible: Always Steps to Reproduce: 1.Compile attached sample code 2.Run code with arg > 2048 3.Code crashes when file size reaches 2048MB This sample code works fine in RedHat 7.3 with g++ 2.96 Actual Results: Error message "File size limit exceeded" File is not written beyond 2048MB Expected Results: File of correct size is written Additional info: #define _FILE_OFFSET_BITS 64 #include <iostream> #include <fstream> using namespace std; #include <stdlib.h> const char* const filename = "HUGEFILE"; int main(int argc, char** argv) { if (argc < 2) { cerr << "Syntax: " << argv[0] << " <nr_of_mbytes>" << endl; return 1; } int n = atoi(argv[1]); ofstream file(filename); if (n <= 0) return 0; const int BUFSIZE = 1 << 20; char* buf = new char[BUFSIZE]; while (n > 0) { file.write(buf, BUFSIZE); --n; if (n % 64 == 0) cerr << n << " MB left, writing to " << filename << endl; } }
Works just fine with gcc-c++-3.4.2-2.