Highly placed sources report that Eivind Tagseth wrote:
> 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.
Dohh! Stupid me, wasn't paying attention. Changed "1000" to "999" and "%ld"
to "%d" and it runs without problems. So, I have no idea what's going on with
the original poster's system.
> 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
$ ulimit -a
core file size (blocks) 0
data seg size (kbytes) unlimited
file size (blocks) unlimited
max memory size (kbytes) unlimited
stack size (kbytes) 8192
cpu time (seconds) unlimited
max user processes 256
pipe size (512 bytes) 8
open files 256
virtual memory (kbytes) 2105343
After I changed the array bounds to correct values, it ran just fine. I
suppose I should change the core file size for my mortal user's account, but
it's generally not a problem.
> $ ./test
> Segmentation fault (core dumped)
> $ ulimit -s 8196
> $ ./test
> i[999][999] = 1998
Kurt
--
Informix on Linux FAQ
http://www.xmission.com/~kwall/iolfaq/english/iolfaq.html
http://www.xmission.com/~kwall/iolfaq/spanish/iolfaq.html (Spanish)
http://www.xmission.com/~kwall/iolfaq/romanian/iolfaq.html (Romanian)