g77 and array limits

David Ronis ronis@ronispc.chem.mcgill.ca
Tue Apr 22 19:39:00 GMT 2003


Toon Moene writes:
 > David Ronis wrote:
 > 
 > > Hi Jurgen
 > > 
 > > Here's a simple test program (that fails)
 > > 
 > >       complex*16 foo(10000,10000)
 > >       integer i,j
 > >       save foo
 > > 
 > >       do i=1,10000
 > >          do j=1,10000
 > >             foo(i,j)=i+j
 > >          end do
 > >       end do
 > >       write(*,*)foo(1,1),foo(10000,10000)
 > >       stop
 > >       end
 > > 
 > > 
 > > with g77 3.2.2
 > > 
 > > I get:
 > > 
 > > g77 -static -O0 -Wall test.f
 > > test.f: In program `MAIN__':
 > > test.f:1: 
 > >          complex*16 foo(10000,10000)
 > 
 > I'm sorry, but I don't get this with 3.2.2 (actually, 3.2.2 prerelease 
 > 20021207).
 > 
 > Please check with -v what the exact version of the compiler is that you 
 > are using.
 > 

You are correct.  I must have been using gcc-2.95.3; as you said, with
3.2.2 it compiles.  However, it still crashes until you reduce the array
dimension (as described in the latter part of the original post).
With the dimensions as above, the array is equivalent to an array of
400 000 000 reals, and should run if the g77 info page I mentioned is
correct.

Here's an even simpler test:

#define N 10000

      real foo(N*N*4)
      integer i
      save foo
	
      do i=1,N*N*4
         foo(i)=i
      end do
      write(*,*)foo(1),foo(N*N*4)
      stop
      end
	

I compile (with 3.2.2)

/usr/bin/g77 -O0 -static -Wall bar.F -static

and when I run:

a.out

Segmentation fault (core dumped)

(it works if I cut the size in half)

David



More information about the Gcc mailing list