Skip to content

COR062 stat-without-errmsg ​

warning opt-in

An allocate/deallocate has stat= but no errmsg=.

Why ​

stat= only tells that the statement failed; errmsg= gets the runtime's explanation (already allocated, out of memory, ...). Without it the error handler can only print a number.

Reported ​

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

Preferred ​

fortran
allocate(a(n), stat=ierr, errmsg=msg)

Suppressing ​

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

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

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

Equivalent ​

Fortitude rule C183 (see Lint Rules).