Bug 111596 - cannot write files larger then 2048MB
Summary: cannot write files larger then 2048MB
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc   
(Show other bugs)
Version: 9
Hardware: i686 Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
Depends On:
TreeView+ depends on / blocked
Reported: 2003-12-05 21:02 UTC by Need Real Name
Modified: 2007-04-18 16:59 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-10-03 22:28:09 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description Need Real Name 2003-12-05 21:02:30 UTC
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:

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);
    if (n % 64 == 0)
      cerr << n << " MB left, writing to " << filename << endl;

Comment 1 Jakub Jelinek 2004-10-03 22:28:09 UTC
Works just fine with gcc-c++-3.4.2-2.

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