Is pointing to a target dummy argument safe after return?

Note the term pedantic mode; also what @certik with LFortran refer to “strict” mode.

Thinking even more pedantically or constraining oneself further with some strict rules when in comes to code design toward the kind of use cases that drive questions like in the original post here is a safer way to proceed.

An aspect of such strictness can be to

  • Avoid altogether a dummy argument with the POINTER attribute that is also not intent(in).

Basically it means to strive for code designs that do not require and make use of “getter” procedures of the type such as foo in the original post.