In another thread (about the US administration advocating the use of memory safe languages) I mentioned a chart I used to maintain which compared different compilers with regard to their run-time error checking.
That chart is very old, and I have now put an updated version at Is Fortran “Memory Safe”? - Fortran UK, paying particular attention to the memory safety issue. I know that Ian and Jane at Fortranplus have also been publishing data, but for different compilers.
- I tested Silverfrost 9.0, gfortran 12.3, Intel ifx 2024.0.2, nvFortran 24.3 and NAG 7.1 on a Windows machine (using WSL for nvFortran)
- The FH1 test was removed (I believe F2018 permits a file to be opened simultaneously on multiple units)
- I used a different benchmark for timing, and added an extra row for optimized timings.
- I removed the floating point exception tests, because I think they don’t really relate to memory safety. I kept the integer overflow test.
- I added a row for garbage collection, which I believe the Linux version NAG 7.1 has. (I haven’t tested it.)
My conclusion is that Fortran can be regarded as “Memory Safe” if the run time tests in that chart are enabled. I think some tests may even go beyond what other reportedly memory safe languages do. The main issue I see is the possibility of memory leaks. I think these can only occur when allocating memory using pointers (allocatable arrays and scalars cannot leak), and it’s possible NAG has that covered too.