Subject: Re: Bus error - simple (?) C program
To: None <claude.marinier@dreo.dnd.ca>
From: Peter Seebach <seebs@plethora.net>
List: netbsd-help
Date: 09/10/2001 09:23:16
In message <Pine.NEB.4.31.0109100918430.1097-100000@behemoth.dreo.dnd.ca>, Clau
de Marinier writes:
>I have been staring at this for a few days. There is likely an obvious
>error in this code but I have not seen it yet. Could someone please point
>it out to me? (I am beginning to suspect that it has to to with internal
>addressing of the matrix elements.)
Sure.
>/*
> * Test program with a big matrix.
> */
>
>#include <stdio.h>
>#include <stdlib.h>
>
>#define N 10000
>
>int main( void )
>{
> int i;
> float matrix[N][N];
You can't do this.
It is simply not portable in C to declare an object over about 64k. While
NetBSD lets you declare objects somewhat larger, you've clearly reached
one of the limits.
Allocate this as an array of pointers, and then malloc them individually.
-s