COR022 missing-default-pointer-initialisation
warning enabled by defaultA pointer component of a derived type has no default initialisation (=> null()).
Why
A pointer component without default initialisation starts with an undefined association status, not a disassociated one: associated(obj%p) on a fresh object is not allowed and returns garbage in practice, so code that tests it before use crashes or follows a wild pointer. => null() in the component declaration makes every new object start disassociated.
Reported
fortran
type :: node
type(node), pointer :: next
end type nodePreferred
fortran
type :: node
type(node), pointer :: next => null()
end type nodeSuppressing
For one occurrence, with the reason on the same line (or alone on the line before the statement):
fortran
! fobis: ignore[COR022] <why this occurrence is fine>For the whole project, ignore = COR022 in the fobos [lint] section.
Equivalent
Fortitude rule C101 (see Lint Rules).