delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/07/21/09:30:24

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Lines: 53
X-Admin: news AT aol DOT com
From: sterten AT aol DOT com (Sterten)
Newsgroups: comp.os.msdos.djgpp
Date: 21 Jul 2004 13:19:33 GMT
References: <2m6rscFjl139U3 AT uni-berlin DOT de>
Organization: AOL Bertelsmann Online GmbH & Co. KG http://www.germany.aol.com
Subject: Re: strange error
Message-ID: <20040721091933.06719.00001806@mb-m13.aol.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

 >
 >> I think I figured out where the problem is.
 >
 >I don't think so.

that's right

 >> I have always been using things like R[99}={0}; thinking that all 99
 >> entries of the array are initialized with 0, 
 >
 >And they will be.  Go look at things in the debugger if you don't
 >believe me.
 >
 >Actually, since you define all your variables at file scope, so they're
 >all of static storage duration, they'll all be initialized to zero 
 >even if you don't supply any initializer.  I.e. in the case at hand, a
 >simple 
 >
 >	int R[99];
 >
 >would have worked just as well.
 >
 >> but apparantly only the first value is zero while the others are
 >> undefined and (almost) unpredictable.
 >
 >What makes you say that?  What evidence do you have to support this?

I tried R[99]={770} and then found that only the first value was 770,
so I concluded that the other values are undefined and only accidently
zero in most cases.

 >It's actually much more likely that you're overrunning one of the other
 >arrays and thus stomping into the area allocated to R[].
 >
 >Which brings me to one more issue with your sourcecode I wanted to
 >point out earlier, but didn't: it's full of statically sized arrays
 >[99] [999], [22], and so on, but you allow arbitrarily large
 >dimensions 'n' to be passed to the actual program.  That's risky at
 >best, and may quite possibly lead to exactly the kind of problems
 >you're running into.

the assigned arrays should be big enough in this case

my previous assumption concerning 
 program size as the reason is also doubtful,
since it could change from "running" to "error" when I just
only change one (nonimportant) variable name from "p" to "o" ...
And it only crashes after all solutions are found.
Weird. I give up for the moment now.
I have no diagnosis but the remedy is "-g".


--Guenter

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019