Skip to content

Don't require that @inbounds depends only on local information #54270

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

Merged
merged 5 commits into from
Jul 2, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -851,11 +851,11 @@ end

Using `@inbounds` may return incorrect results/crashes/corruption
for out-of-bounds indices. The user is responsible for checking it manually.
Only use `@inbounds` when it is certain from the information locally available
that all accesses are in bounds. In particular, using `1:length(A)` instead of
`eachindex(A)` in a function like the one above is _not_ safely inbounds because
the first index of `A` may not be `1` for all user defined types that subtype
`AbstractArray`.
Only use `@inbounds` when you are certain that all accesses are in bounds (as
undefined behavior, e.g. crashes, might occur if this assertion is violated). In
particular, using `1:length(A)` instead of `eachindex(A)` in a function like
the one above is _not_ safely inbounds because the first index of `A` may not
be `1` for all user defined types that subtype `AbstractArray`.
"""
macro inbounds(blk)
return Expr(:block,
Expand Down