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

Observation

Description

1

Bad memory access

The place 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
        

Copyright © 2010, Intel Corporation. All rights reserved.