Skip to content

COR120 unreachable-statement ​

warning enabled by default

A statement follows return, stop, exit, cycle or go to in the same block: it never runs.

Why ​

Code after an unconditional transfer of control cannot execute unless it carries a label that some go to targets. It is usually a leftover of debugging (an early return above real work) or a misplaced statement that was meant to run before the transfer.

Reported ​

fortran
x = x + 1
return
print *, x

Preferred ​

fortran
x = x + 1
print *, x
return

Suppressing ​

For one occurrence, with the reason on the same line (or alone on the line before the statement):

fortran
! fobis: ignore[COR120] <why this occurrence is fine>

For the whole project, ignore = COR120 in the fobos [lint] section.

Equivalent ​

Fortitude rule C191 (see Lint Rules).