Static Analysis Problem Type Reference

ALLOCATABLE array referenced before allocation

A FORTRAN ALLOCATABLE array was used before being allocated.

FORTRAN ALLOCATABLE variables must acquire storage before they can be referenced. To allocate memory, use the ALLOCATE intrinsic function.

ID

Code Location

Description

1

Bad memory access

The place where the variable was accessed

Example


integer, allocatable, dimension(:) :: a
a(1) = 1
! "a" is referenced before allocation
print *,a(1)
allocate(a(5))
a = 5
print *,a
deallocate(a)
end