Re: EXC_BAD_ACCESS error
Re: EXC_BAD_ACCESS error
- Subject: Re: EXC_BAD_ACCESS error
- From: Jean-Daniel Dupas <email@hidden>
- Date: Mon, 11 Oct 2010 15:57:24 +0200
Accessing an array using a negative index is undefined in C++, so may crash, or may not depending the compiler, the OS, the phase of the moon, etc…
If you want to know why it works for 32 bits and not 64 bits, you can also read this article.
http://www.devx.com/tips/Tip/41349
But the correct way to handle this is to rewrite your loop to avoid negative index.
Le 11 oct. 2010 à 15:49, McLaughlin, Michael P. a écrit :
> 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
>
> However, the underlying algorithm is really OK and, in fact, I do *not* get
> this error with exactly the same code when it is part of another
> Cocoa/Objective-C++ project.
>
> Can anyone shed any light on this? I have used this code for a long time
> and have never gotten this error before.
>
> I tried to look at the Build Results but that window says only "Build
> Succeeded" and there seems to be no icon (that I could find) that will bring
> up the gcc build command unless there is some warning or compile error.
>
> Thanks for any tips.
>
> --
> Mike McLaughlin
>
> _______________________________________________
> 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
-- Jean-Daniel
_______________________________________________
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