From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Weird static/dynamic allocation crash... Date: Tue, 22 Jul 1997 16:05:07 +0000 Organization: Two pounds of chaos and a pinch of salt Lines: 30 Message-ID: <33D4DA33.14F0@cs.com> References: <3 DOT 0 DOT 1 DOT 32 DOT 19970722035329 DOT 0069bfd4 AT postoffice DOT tidalwave DOT net> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp220.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Kenn White wrote: > > I'm having trouble with the *very* simple program below. > It seems that when the integer x is forceably set (i.e., > statically allocated), I get a run-time crash. When > is is malloced, however, everything is fine. > #define SIZE 1000000 It's this. The default stack in DJGPP programs is 256K, and does not grow dynamically. It's no wonder you're getting a stack fault here; I'm amazed you didn't have worse problems. FYI, x is not being declared statically; it's being declared automatically. If you use the static qualifier, or declare it globally, your program will work. For information on setting the stack size of DJGPP programs, and other trivia, see chapter 15.9 of the FAQ (v2/faq210b.zip from SimTel or online at http://www.delorie.com/djgpp/v2faq/). hth! -- --------------------------------------------------------------------- | John M. Aldrich, aka Fighteer I | mailto:fighteer AT cs DOT com | | * Proud user of DJGPP! * | http://www.cs.com/fighteer | | ObJoke: If Bill Gates were a robber, not only would he | | shoot you, but he'd send you a bill for the bullets. | ---------------------------------------------------------------------