Skip to content

Commit 1193997

Browse files
Don't require that @inbounds depends only on local information (#54270)
Co-authored-by: Steven G. Johnson <[email protected]>
1 parent 2712633 commit 1193997

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

base/essentials.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -864,11 +864,11 @@ end
864864
865865
Using `@inbounds` may return incorrect results/crashes/corruption
866866
for out-of-bounds indices. The user is responsible for checking it manually.
867-
Only use `@inbounds` when it is certain from the information locally available
868-
that all accesses are in bounds. In particular, using `1:length(A)` instead of
869-
`eachindex(A)` in a function like the one above is _not_ safely inbounds because
870-
the first index of `A` may not be `1` for all user defined types that subtype
871-
`AbstractArray`.
867+
Only use `@inbounds` when you are certain that all accesses are in bounds (as
868+
undefined behavior, e.g. crashes, might occur if this assertion is violated). For
869+
example, using `1:length(A)` instead of `eachindex(A)` in a function like
870+
the one above is _not_ safely inbounds because the first index of `A` may not
871+
be `1` for all user defined types that subtype `AbstractArray`.
872872
"""
873873
macro inbounds(blk)
874874
return Expr(:block,

0 commit comments

Comments
 (0)