Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cuae2!ihnp4!ptsfa!lll-lcc!seismo!rochester!ritcv!rocksvax!rocksanne!sunybcs!cald80!bob From: bob@cald80.UUCP Newsgroups: comp.lang.c,comp.unix.questions Subject: Re: Question on large arrays in C Message-ID: <848@cald80.UUCP> Date: Fri, 13-Feb-87 00:10:30 EST Article-I.D.: cald80.848 Posted: Fri Feb 13 00:10:30 1987 Date-Received: Sat, 14-Feb-87 14:56:49 EST References: <1051@uwmacc.UUCP> Reply-To: bob@cald80.UUCP (Bob Meyer) Organization: Calspan Advanced Technology Center Lines: 54 Keywords: C unix Xref: utgpu comp.lang.c:1039 comp.unix.questions:1031 In article <1051@uwmacc.UUCP> jwp@uwmacc.UUCP (Jeffrey W Percival) writes: :I am running 4.3BSD on a MicroVax II. :I have a simple program: : :---------- :#include :#define N 20480 :main() :{ : double x[N]; : double y_1[N]; : double y_2[N]; : double y_3[N]; : double y_4[N]; : char *l = ""; : : fprintf(stdout, "hi\n"); : exit(0); :} :---------- : :When I run it, I get "Segmentation violation". :dbx reports the violation to occur on the "char *l" line. :If I move the 5 array declarations up above main(), :under the define statement, the program works OK. :What is wrong with the program as listed above? :-- My compiler (Ancient V7 68000 UNIX) won't even let me do that. I don't think that aggregate assignments inside a block are not allowed on most systems that I hack on. Also remember that local variables hang out on the stack. Your compiler may not catch a stack overrun (409600 Kbytes may be a bit much even for a VAX). I generally stuff large arrays out in global area anyway. That keeps you from having to pass them all the time. No flames, I know that globals are generally to be avoided unless really necessary but I prefer to stuff big stuff out there in case I get stuck on another machine with small stack (8086 and company). On those machines, 64K is all you're allowed in one data segment. Also, the local FORTrashers find globals easier to deal with when trying to figger out what I did (seems that they associate them with unnamed commons or some such). I might be completely off base on this (I don't really dig into VAXEN much and am not sure of the architecture there) but I think that this may be right. -- Bob Meyer Calspan ATC seismo!kitty!sunybcs!cald80!bob decvax!sunybcs!cald80!bob