Re: EXC_BAD_ACCESS error
Re: EXC_BAD_ACCESS error
- Subject: Re: EXC_BAD_ACCESS error
- From: Paul Russell <email@hidden>
- Date: Thu, 14 Oct 2010 07:53:05 +0100
On 11 Oct 2010, at 14:49, McLaughlin, Michael P. wrote:
> Using Xcode 3.2.4 under Mac OS 10.6.4 on a 64-bit Mac Pro, I am getting a
> runtime error of
>
> EXC_BAD_ACCESS
>
> The project is a C++/CoreServices tool. The error seems to arise because
> some legacy (Mersenne Twister) code is trying to dereference a pointer with
> a negative index.
>
> for (j = M;--j;p++)
> *p = p[M-N] ^ TWIST(p[0], p[1]); // M = 397, N = 624
>
One problem I've seen before with gcc on 64-bit (LP64) architectures is that address arithmetic can be erroneous when you have a signed (32-bit) int index and a (64-bit) pointer and the int is negative (because the int is not sign extended to 64 bits as it probably should be). One thing to try is to force the array index to be 64-bit, e.g. in your example:
*p = p[(ptrdiff_t)(M-N)] ^ TWIST(p[0], p[1]);
Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden