Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!hao!oddjob!gargoyle!ihnp4!laidbak!daveb
From: daveb@laidbak.UUCP (Dave Burton)
Newsgroups: comp.lang.c
Subject: Re: Limit to array size under cc?
Message-ID: <1265@laidbak.UUCP>
Date: Wed, 2-Dec-87 00:23:42 EST
Article-I.D.: laidbak.1265
Posted: Wed Dec  2 00:23:42 1987
Date-Received: Sat, 5-Dec-87 14:16:05 EST
References: <3537@ames.arpa> <9583@mimsy.UUCP>
Reply-To: daveb@laidbak.UUCP (Dave Burton)
Organization: is pretty bad/My method of
Lines: 36

In article <9583@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
>In article <3537@ames.arpa> lamaster@pioneer.arpa (Hugh LaMaster) asks:
>>Is there a limit to the maximum size of an array using cc?
>and notes that the following program (my condensed version) crashes:
>	#define NR 128767
>	main() { int red[NR]; red[0] = 0; }
>   Solution: use the C-shell built in `limit' command, e.g.,
>   `limit stacksize 1m' (yes, megabytes should be M, but csh
>   refuses to believe in millibytes :-) so you may use lowercase).
>   The built-in `unlimit' command raises a limit to its maximum
>   value.  Alternatively, the program itself can set its stacksize
>   limit.  For details, see man 1 csh and man 2 setrlimit.

Or better yet, use some variant of MALLOC(3), maybe:
#include 
#define	NR	128768	/* or other suitably large value */
main()
{
	int *red;
	if ((red = (int*)malloc(NR)) == NULL) {
		fprintf(stderr, "cannot alloc %ld bytes\n", NR);
		exit(1);
	}
	red[0] = 0;
	/* etc. */
	exit(0);
}

Changing the shell limit will allow that invocation to work,
but future invocations will fail the same as the original.
Fix your program, don't fix BSD.
-- 
--------------------"Well, it looked good when I wrote it"---------------------
 Verbal: Dave Burton                        Net: ...!ihnp4!laidbak!daveb
 V-MAIL: (312) 505-9100 x325            USSnail: 1901 N. Naper Blvd.
#include                           Naperville, IL  60540