Re: GC crash due to being naughty
Re: GC crash due to being naughty
- Subject: Re: GC crash due to being naughty
- From: Ben Haller <email@hidden>
- Date: Thu, 15 Oct 2009 20:18:23 -0400
On 15-Oct-09, at 8:10 PM, Oftenwrong Soong wrote:
Hi Ben,
You say the crash occurs in this line:
individuals[individualCount++] = individualsForPop[i];
The problem may be in the post-increment (individualCount++). IIRC,
there is no agreed-upon compiler standard as to whether the post-
increment will occur before or after the assignment. It is possible
that you're using the bytes after the end of the array as a pointer,
which points to a random location rather than to your desired data.
If you want the increment to happen after the assignment, do this:
for (i = 0; i < individualCountForPop; ++i) {
individuals[individualCount] = individualsForPop[i];
individualCount++;
}
If you want it before, just reverse the order of the two lines.
I've had many a headache in the past with things like this!!
Huh. Could've sworn that was well-defined. Well, I've been away
from coding for about six years now, guess I've gotten a little rusty.
In any case, this change does not fix the problem; same crash, on
the assignment line.
Ben Haller
Stick Software
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden