How to verify safe automatic deallocation of Fortran allocatable arrays after a compiler upgrade?
0 reputation · 17 Aug 2025, 18:00 UTC
Consider a legacy Fortran program that uses allocatable arrays inside a subroutine and relies on the automatic deallocation feature introduced in Fortran 2003, where arrays are deallocated when they go out of scope. The program has been successfully built and run with Compiler X version Y.
After upgrading to Compiler X version Z, there is uncertainty whether the automatic deallocation still occurs correctly, potentially leading to memory leaks or undefined behavior. The goal is to confirm that the upgrade does not break this language guarantee and to determine how to detect any regression and safely revert if needed.
How can one test that automatic deallocation of allocatable arrays behaves as expected after a compiler upgrade? What diagnostic tools or compiler flags can help detect missing deallocation? What is a safe strategy to revert to the previous compiler version if the upgrade introduces regressions?