-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"for x in A" array iteration should imply @inbounds? #11350
Comments
Have you tried putting the |
@ScottPJones, you're right,
which is only one instruction longer than for I guess the real issue is that |
It's good that you caught this... until this is fixed, at least I know how to improve the "abstract" versions of operating on strings (after #11004 hopefully is merged) |
I guess the problem is that But for debugged iterators, like the built-in array iterators, can we put an |
We could, although the |
So, it sounds like it still needs to be left up to the programmer to add |
@johnmyleswhite, you mean if the array is resized inside the body of the for loop? |
@stevengj, that's an example of what I had in mind. |
I don't think resizing should present an issue for Array iteration since Some related discussion in #7799 (comment). |
Another case that might give trouble is if someone uses Or if someone tampers with an iterator. You shouldn't do that of course, but should it be able to cause memory corruption? |
@toivoh,I'm thinking that the |
That might be reasonable, but it should only apply to the iterator operations. But I still think it would have to be a new kind of |
I'm going to make the call that this would be too dangerous. |
I guess the Polly work could help hoisting bounds check in the standard cases? |
See also #15291 for a way to address this. |
Here's something odd I noticed when looking at #11241. Compare the following two functions:
I would have thought that these would be roughly equivalent in terms of speed, but
code_native
shows that vastly less code is generated forbar
than forfoo
:Note in particular that
foo
apparently still thinks that it can throw aBoundsError
, even thoughfor c in s
should always be in-bounds.Is this a known issue?
The text was updated successfully, but these errors were encountered: