delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/09/05:51:43

Date: Thu, 9 Oct 1997 11:50:26 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: "Salvador Eduardo Tropea (SET)" <salvador AT inti DOT edu DOT ar>
cc: Herman Geza <hg211 AT hszk DOT bme DOT hu>, djgpp AT delorie DOT com
Subject: Re: Compiler crashes...
In-Reply-To: <m0xIwGo-000S23C@inti.gov.ar>
Message-ID: <Pine.SUN.3.91.971009115004.1612D-100000@is>
MIME-Version: 1.0

On Wed, 8 Oct 1997, Salvador Eduardo Tropea (SET) wrote:

> Bad news:
> GCC doesn't support big arrays with initialization, like this:
> 
> char XXX[100000]={ 1,2,....
> ...
> ... 99999 };
> 
> The compiler will crash or if you have luck (like I have) it will
> report out of virtual memory. Seems that gcc uses MUCH more memory
> for this that what we can think. For example: 300000 elements needs
> more than 40Mb.

Are you sure?  Can you post a short program that shows this problem?

Testing with a program that I used (see below) indicates that it takes
cc1 about 10MB to compile it.  But I never had any crashes or "out of
memory" messages.

#include <stdio.h>
#include <stdlib.h>

unsigned xxx[100000] = {
  1, 2, 3, 4, 5, 6, 7, 8, 9, 10,  /* 9,999 lines like this  */
  1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
  ....
  ....
  1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
};

int main (void)
{
  return printf ("%d\n", xxx[rand() % 3] + xxx[rand() % 4]);
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019