Ownership for Fortran pointers

While I agree that this seems like the most robust ideal case, I have the feeling that this seemingly simple addition, would make its development and adoption longer (not happen at all?).

My feeling remains that IF the action of allocating a pointer variable (that the language already allows) triggers an internal state (known to the processor, transparent for the user), then, the processor would be able to alert of memory freeing errors earlier at compile time.

If proposed this way, the adoption might be faster because it would not require changing declaration of variables. It might of course trigger some warnings/errors on existing code which could be deactivated with some legacy flag. Keeping on this line of thoughts, then one would be able to query if(allocated(..)) on a pointer entity. Which would close the unsymmetric and inconsistent definition of being able of allocating but not querying on the data ownership of the pointer.

I tried to muck-up the behavior here Compiler Explorer very fast… this would need some extra thought to put together limit cases, the improvements that such design should bring and the non-backward compatible behaviors that might be dangling behind the corner.

1 Like