# Array Bounds Checking - Standard Behavior?

**URL:** <https://fortran-lang.discourse.group/t/array-bounds-checking-standard-behavior/5782>\
**Category:** Help\
**Created:** [May 9, 2023, 1:23pm UTC](https://fortran-lang.discourse.group/t/array-bounds-checking-standard-behavior/5782 "2023-05-09T13:23:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [May 9, 2023, 1:35pm UTC](https://fortran-lang.discourse.group/t/array-bounds-checking-standard-behavior/5782/2 "2023-05-09T13:35:40Z")

</div>

I think the answers to both of your questions are “no”. Btw,  
`gfortran -fbounds-check xcheck_bounds.f90` for

```auto
program main
  implicit none
  integer :: z(2)
  z = [1, 2]
  print*,z(sum(z)) ! out-of-bounds detected at run time
  print*,z(3) ! out-of-bounds detected at compile time
end program main

```

says

```auto
xcheck_bounds.f90:6:11:

    6 | print*,z(3) ! out-of-bounds detected at compile time
      | 1
Warning: Array reference at (1) is out of bounds (3 > 2) in dimension 1

```

at compile time and gives at run time

```auto
At line 5 of file xcheck_bounds.f90
Fortran runtime error: Index '3' of dimension 1 of array 'z' above upper bound of 2

```

---

_[View the full topic](https://fortran-lang.discourse.group/t/array-bounds-checking-standard-behavior/5782)._
