Static Analysis Problem Type Reference

Optional parameter not checked

An optional parameter must be verified to be present before it was used.

Using an optional parameter without first verifying that it is present is unsafe. If the parameter is absent, a null pointer exception will occur.

ID

Code Location

Description

1

Bad memory access

The place where the optional parameter was used

Example


subroutine mysub(j)
integer, optional :: j
! This is good usage
if (present(j)) print *, j
! This is bad usage
print *, j
end

call mysub(5)
call mysub()
end