Re: EXC_BAD_ACCESS error
Re: EXC_BAD_ACCESS error
- Subject: Re: EXC_BAD_ACCESS error
- From: Andreas Grosam <email@hidden>
- Date: Thu, 14 Oct 2010 16:13:53 +0200
On Oct 14, 2010, at 8:53 AM, Paul Russell wrote:
> 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).
This would mean, that the GCC Compiler has broken pointer arithmetic in this architecture (LP64), namely the conversion from 32 bit to 64 bit integral types. This is hard to believe - since virtually every program relies on this, and because of regression tests.
> 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]);
According the standard, the type of ptrdiff_t is implementation-defined (a signed integral) - so this is no guarantee that the array index becomes 64-bit ;)
The code runs correctly on my Mac, so the culprit must be elsewhere :)
> 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