# How to configurate bound checks at statup?

**URL:** <https://discourse.julialang.org/t/how-to-configurate-bound-checks-at-statup/39248>\
**Category:** General Usage\
**Tags:** question, optimization, startup\
**Created:** [May 10, 2020, 9:45pm UTC](https://discourse.julialang.org/t/how-to-configurate-bound-checks-at-statup/39248 "2020-05-10T21:45:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JosephPollacco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josephpollacco/32/51404_2.png) [@JosephPollacco](https://discourse.julialang.org/u/JosephPollacco)\
**Post date:** [May 10, 2020, 9:45pm UTC](https://discourse.julialang.org/t/how-to-configurate-bound-checks-at-statup/39248/1 "2020-05-10T21:45:43Z")

</div>

For well tested code it will be nice to have an option at the **startup** which disables the **check bounds**. According to the book **JULIA HIGH PERFORMACE** this is possible with the following option:

```julia
-checks-bounds=no

```

Nevertheless, I was not able to get it working and I will be grateful if you could let us know how to get the -checks-bounds working at startup?

Below is what is stated in the book:

> "The julia runtime can use a command-line flag to set up bound-checking behavior for the entire session. The _-check-bounds_ can take two values: _yes_ and _no_ These options will override any macro annotation in the source code.

---

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [May 11, 2020, 12:27am UTC](https://discourse.julialang.org/t/how-to-configurate-bound-checks-at-statup/39248/2 "2020-05-11T00:27:30Z")

</div>

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
$ 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
$ 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> 

```

---

<div class="post-metadata">

**Author:** ![JosephPollacco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josephpollacco/32/51404_2.png) [@JosephPollacco](https://discourse.julialang.org/u/JosephPollacco)\
**Post date:** [May 11, 2020, 4:06am UTC](https://discourse.julialang.org/t/how-to-configurate-bound-checks-at-statup/39248/3 "2020-05-11T04:06:19Z")

</div>

Thanks it works but it is **tedious** to get it working:

```julia
julia --check-bounds=no

```

I am wandering if there is an easier way to get the _julia --check-bounds=no_ steps in Windows correct?

a) Open a CMD?

b) cd C:\JULIA\Julia-1.4.1\bin

c) type _julia --check-bounds=yes_

This will open up the julia editor.

---

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [May 11, 2020, 11:06am UTC](https://discourse.julialang.org/t/how-to-configurate-bound-checks-at-statup/39248/4 "2020-05-11T11:06:33Z")

</div>

I believe with windows you can create a shortcut and modify it to always include the “–check-bounds=yes” when launching julia. If you browse to the bin directory and right click on the exe there should be a “create shortcut” I believe. Once that is created you can edit it to add the command line.

Or you can probably right click on the shortcut in the start menu and modify that one as well.

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [April 18, 2024, 11:26pm UTC](https://discourse.julialang.org/t/how-to-configurate-bound-checks-at-statup/39248/5 "2024-04-18T23:26:58Z")

</div>

How to do this in VS code?
