Seems to be working for me.
With --check-bounds=no the @inbound declaration is honored (Julia assumes the access is valid) and @boundscheck code is removed.
$ julia --check-bounds=no
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.4.1 (2020-04-14)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> foo(a) = @inbounds a[1024]
foo (generic function with 1 method)
julia> bar(a) = (@boundscheck throw("out of bounds"))
bar (generic function with 1 method)
julia> foo("abc")
'\0': ASCII/Unicode U+0000 (category Cc: Other, control)
julia> bar("abc")
julia>
With --check-bounds=yes @inbounds is ignored (Julia still checks) and @boundscheck is left in the code.
$ julia --check-bounds=yes
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.4.1 (2020-04-14)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> foo(a) = @inbounds a[1024]
foo (generic function with 1 method)
julia> bar(a) = (@boundscheck throw("out of bounds"))
bar (generic function with 1 method)
julia> foo("abc")
ERROR: BoundsError: attempt to access String
at index [1024]
Stacktrace:
[1] checkbounds at ./strings/basic.jl:194 [inlined]
[2] codeunit at ./strings/string.jl:89 [inlined]
[3] getindex at ./strings/string.jl:210 [inlined]
[4] foo(::String) at ./REPL[1]:1
[5] top-level scope at REPL[3]:1
julia> bar("abc")
ERROR: "out of bounds"
Stacktrace:
[1] bar(::String) at ./REPL[2]:1
[2] top-level scope at REPL[4]:1
julia>