How to detect uninitialized arguments?

The easiest way for me, has been to use the online or offline installer packages, e.g. if you visit: https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html#fortran

With the online installer, you can select later if you need other components (say the C++ compiler or the MKL package). The whole oneAPI toolkit is big indeed. :elephant:


It looks like the gfortran unused argument detection is a bit faulty. If you remove all the statements entirely, you will see that gfortran does provide warnings:

/app/example.f90:1:16:

    1 | subroutine foo(x, y)
      |                1
Warning: Dummy argument 'x' at (1) was declared INTENT(OUT) but was not set [-Wunused-dummy-argument]
/app/example.f90:1:19:

    1 | subroutine foo(x, y)
      |                   1
Warning: Dummy argument 'y' at (1) was declared INTENT(OUT) but was not set [-Wunused-dummy-argument]

So it looks like y = x makes the compiler think that both arguments are used, despite the use of x being in violation of the intent(out) argument. The name of warning flag would imply it checks if a dummy argument appears in the executable section of a procedure, but not if it is actually used correctly. If not found it prints a message.

That said, one possibility with gfortran would be to initialize integers to some strange value, -finit-integer=-999999. Hopefully this would trigger some other error you could detect (for instance a runtime bound violation).

1 Like