Loop counter modified

A FORTRAN loop counter was modified by a function called from within the loop.

FORTRAN does not allow modifications to the loop counter in a DO loop. Direct attempts to modify the loop counter directly are flagged by the compiler, but the compiler does not catch the case where the loop counter is modified by passing the loop counter to a subroutine that modifies its dummy argument. This diagnostic catches that case.

ID

Observation

Description

1

Call site

Place where function was called inside the loop

2

Memory write

This shows where the variable was modified

Example

subroutine IModify(k)
    integer :: k
    k = k+1
end

    real, dimension(5) :: a
    integer :: i
    do i = 1,5
        a(i) = 3.14
        call IModify(i)
! do-counter "i" is modified in "IModify" call
    end do
    print *,a
end    
        

Copyright © 2010, Intel Corporation. All rights reserved.