Re: Xcode 7 hanging with multi-dimensional vector resize
Re: Xcode 7 hanging with multi-dimensional vector resize
- Subject: Re: Xcode 7 hanging with multi-dimensional vector resize
- From: Michael McLaughlin <email@hidden>
- Date: Fri, 11 Dec 2015 14:36:25 -0500
No. As my code showed, I was implementing 1-based (FORTRAN) arrays.
While I am still curious about this, I think I’ll just flatten my matrices and do the indexing manually. This is feasible for me since my matrices are never more than 3-D. I tried this and it does not hang. On Dec 11, 2015, at 2:11 PM, Jens Alfke < email@hidden> wrote:
On Dec 11, 2015, at 10:23 AM, Michael McLaughlin < email@hidden> wrote:
v2.resize(length); for (c = 0;c <= length;c++) v2[c].resize(length2);
You have an off-by-one bug and are writing past the end of the v2 vector. (The “<=“ should be “<“.) For random reasons depending on how the heap happens to be laid out at the moment, this will sometimes be benign and sometimes cause terrible problems.
PSA: Turning on the Address Sanitizer in Xcode 7 (it’s in the Run and Test sections of the scheme editor) would probably have caught this at the moment it occurred.
—Jens
|
_______________________________________________
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