Array restriction in g77

Toon Moene toon@moene.indiv.nluug.nl
Tue Nov 30 23:39:00 GMT 1999


Olaf Cirpka wrote:

> I have installed the latest release of g77 on a pentium III running under
> Debian Linux (kernel 2.0.38).

> g77 version 2.95.2 19991024 (from FSF-g77 version 0.5.25 19991024)
> i686-pc-linux-gnu

> The computer has 1 GB RAM, and the system recognizes the memory
> (/proc/meminfo contains "MemTotal:   1032628 kB"). However, when
> I define arrays that use more than 512 MB RAM, I receive the error message
> "array too large to handle".

> Example: test.f
> 
>       PROGRAM HALLO
>       DOUBLE PRECISION A(67108864)
>       WRITE(*,*) "HALLO"
>       END
> 
> End example

> output for g77 test.f:
> 
>          DOUBLE PRECISION A(67108864)
>                           ^
> Array `a' at (^) is too large to handle
> 
> End output
> 
> With A(67108863) everything is fine.

Yep, this is a limitation in the compiler that I myself do not
understand completely.

The Fortran Frontend is requesting information from the "middle" end of
the compiler about the size of the array:
static tree
ffecom_check_size_overflow_ (ffesymbol s, tree type, bool dummy)
{

  [ ... some checks ... ]

  if ((tree_int_cst_sgn (TYPE_SIZE (type)) < 0)
      || (!dummy && (((TREE_INT_CST_HIGH (TYPE_SIZE (type)) != 0))
                     || TREE_OVERFLOW (TYPE_SIZE (type)))))
  { ... "Array is too large" ... }

and is then told that it is too large.

The only way that can be is when all size and offsetting is done in bits
(64 * 67108864 = 2 ** 32).  I know this to be true - however, it still
doesn't explain why the bit-size-and-offset calculations aren't done in
64-bit integer mode.

The only explanation I can come up with for *that* is that it is too
expensive on a 32-bit architecture.

-- 
Toon Moene (toon@moene.indiv.nluug.nl)
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Phone: +31 346 214290; Fax: +31 346 214286
GNU Fortran: http://gcc.gnu.org/onlinedocs/g77_news.html



More information about the Gcc-bugs mailing list