Skip to content

COR060 unchecked-stat ​

warning enabled by default

The stat= variable of an allocate/deallocate is never read afterwards.

Why ​

Passing stat= tells the runtime not to stop on failure: the error is reported only through the variable. If nothing reads it, an allocation failure is silently ignored and the program continues with an unallocated array.

Reported ​

fortran
allocate(a(n), stat=ierr)
a = 0.0

Preferred ​

fortran
allocate(a(n), stat=ierr)
if (ierr /= 0) error stop 'cannot allocate a'

Suppressing ​

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

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

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

Equivalent ​

Fortitude rule C181 (see Lint Rules).