Removing bound checks globally in an interactive session


#1

Does starting an interactive session (or an IJulia notebook from that session) using the command line option “–check-bounds=no” really eliminate all boundary checks across the entire code?

For instance, the following session indicates that a boundary check is still performed.

MacBook-Pro-10:spt snirgaz$ /Applications/Julia-0.6.app/Contents/Resources/julia/bin/julia --check-bounds=no
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.0 (2017-06-19 13:05 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-apple-darwin13.4.0

julia> a=[1,2,3]
3-element Array{Int64,1}:
 1
 2
 3

julia> a[4]
ERROR: BoundsError: attempt to access 3-element Array{Int64,1} at index [4]
Stacktrace:
 [1] getindex(::Array{Int64,1}, ::Int64) at ./array.jl:520



#2

Put it in a function.

julia> f(a) = a[4];

julia> a = [1,2,3];

julia> f(a)
0

julia> a[4]
ERROR: BoundsError: attempt to access 3-element Array{Int64,1} at index [4]
...

#3

Thanks!