The Assigned GOTO feature was deleted in Fortran 95, but FTN95 still supports that Fortran feature, and there are occasional old Fortran codes that we encounter in which it was used.
The Assigned GOTO is governed by some peculiar rules (see 7.1.1.3 of the Fortran 66 standard, https://wg5-fortran.org/ARCHIVE/Fortran66.pdf ). A variable of type integer may be assigned a statement number (including a Format statement number). That integer variable may no longer be used in contexts where an integer arithmetical value is expected. However, assigning a new integer value to it restores the status of the variable to that of a normal integer variable, and the variable may no longer be used in Assigned GOTO statements until it is set equal to a new statement number with an ASSIGN statement.
The following short code encapsulates a situation where FTN95 used with /CHECK or /CHECKMATE does not help to catch the bug.
program wicked
implicit none
integer pqr
data pqr/789/
!
10 print *,'pqr = ',pqr
if(pqr .gt. 10)then ! invalid comparison when PQR is a stmt.no.
assign 10 to pqr ! now the integer value of PQR is undefined
goto pqr
else
pqr = 1 ! now the stmt.no. value of PQR is undefined
endif
print *,pqr
end
The resulting EXE, when run, loops until it is terminated with a ^C.
Using a single name (PQR) for an integer variable and a statement label was surely an invitation for trouble, and having the compiler issue a suitable warning would help in detecting and fixing bugs of this type -- such as:
PQR - both a numeric value and label assigned to this variable.