Skip to content

OBS002 equivalence-statement ​

warning enabled by default

An equivalence statement.

Why ​

equivalence makes different variables share storage, defeating type checking and optimisation (aliasing). It is obsolescent since Fortran 2018. Use transfer, pointers, or separate variables.

Reported ​

fortran
equivalence (a, b)

Preferred ​

fortran
b = transfer(a, b)

Suppressing ​

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

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

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

Equivalent ​

Fortitude rule OB012 (see Lint Rules).