Static Analysis Problem Type Reference
The type of an actual argument does not match the corresponding formal parameter at a FORTRAN subroutine call.
When a call is compiled, an interface may be available that indicates that the called routine expects optional parameters. If the number of actual arguments is less than the number of dummy arguments, then the compiler will pass null opposite the dummy arguments. If it turns out that the actual definition of the called procedure doesn't match the interface, then this convention could cause a null value to be passed opposite a non-optional dummy argument. This often leads to a null pointer dereference error.
In this case, the call is through a subroutine that is referenced through a dummy argument and the interface in question is the one at the dummy argument declaration.
|
ID |
Code Location |
Description |
|---|---|---|
|
1 |
Definition |
The place where the function was defined |
|
2 |
Call site |
The place where the function was called |
subroutine mysub(j)
integer :: j ! note: dummy argument is not optional
print *,j
end
subroutine icallyou(f)
interface
subroutine f(j)
integer, optional :: j
end subroutine f
end interface
integer :: m
read *, m
call f(m)
call f() ! error here when f refers to mysub
end
program test
interface
subroutine mysub(j)
integer, optional :: j
end subroutine mysub
end interface
call icallyou(mysub)
end