Mail Archives: djgpp/2004/07/21/09:30:24
>
>> 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 -