On Tue, Feb 09, 1999 at 07:07:24AM -0700, Kurt Wall wrote:
>
> Highly placed sources report that S.R.Sathe wrote:
> > Dear sir,
> >
> > I would like to use lage dimensional arrays in gcc. I am unable to
> > access
> > an array of dimension int a[1000][1000]. Please help
>
> Just for grins, the program below compiled without error, but generated
> a bus error when executed. Machine in question is a Pentium II 266 with 128
> MB RAM. What kind of machine do you have? What version of GCC? What error(s)
> do you get?
> int i[1000][1000];
> printf("i[1000][1000] = %ld\n", i[1000][1000]);
^^^^ ^^^^ ^^^^ ^^^^
Those should be 999.
If the program still crashes, check the stack-limit:
$ ulimit -a
core file size (blocks) unlimited
data seg size (kbytes) unlimited
file size (blocks) unlimited
max memory size (kbytes) unlimited
stack size (kbytes) 2048
cpu time (seconds) unlimited
max user processes 256
pipe size (512 bytes) 8
open files 1024
virtual memory (kbytes) 2099199
$ ./test
Segmentation fault (core dumped)
$ ulimit -s 8196
$ ./test
i[999][999] = 1998
Eivind