That’s a good thought.
When it comes to working with data objects with the POINTER attribute, it’s much safer of course to follow some programming practices such as
- Try to avoid “entities” in MODULEs or components with PUBLIC attribute in derived types or variables in the main program from having the POINTER attribute This then mostly leaves only local variables in subprograms or private components of derived types as the instances where such an attribute may get used,
- Try to avoid an object with a POINTER attribute from appearing in an ALLOCATE statement, thereby employing the data pointers only as aliases to named data targets,
- As mentioned above, have a program workflow such that the data pointer gets explicitly nullified as soon as its need gets exhausted,