Static Analysis Problem Type Reference
The type of an actual argument does not match the corresponding formal parameter at a subroutine call.
Specifically, this error occurs when both the actual and formal parameter types are arrays, but the ranks (number of dimensions) of the arrays do not match. Note however that FORTRAN programs often deliberately treat multi-dimensional arrays as if they were single-dimensional arrays so this error is not flagged in that case. This allows a programmer to iterate through all the data in an array using a simple loop, as one might do when setting all elements to zero or searching for a single value anywhere in the array.
This same kind of error can also happen when a FORTRAN dummy argument of type subroutine is invoked. That is, the subroutine that is invoked through a dummy argument might exhibit the same problem as can occur in a direct call. In this case the problem may or may not happen depending on what subroutine was passed to the dummy argument of subroutine type. There will be an additional code location in such cases that identifies the call site where the subroutine argument was passed in.
A variant of this condition is listed as CWE-843: Access of Resource Using Incompatible Type ('Type Confusion') in the Common Weakness Enumeration, a community-developed dictionary of software weakness types.
|
ID |
Code Location |
Description |
|---|---|---|
|
1 |
Call site |
The actual argument that was passed |
|
2 |
Definition |
The definition of the called procedure |
subroutine mysub(m)
integer, dimension(2,3,2) :: m
print *, m
end
integer, dimension(6,2) :: n
n = 1
call mysub(n)
! rank of argument #1 and rank of dummy argument are different.
end