'Argument aliasing' is a term used (more in the C context than with Fortran) to describe situations where the same actual argument is passed by a caller for more than one dummy (formal) argument in a single CALL. The Fortran 95 standard says (http://j3-fortran.org/doc/standing/archive/007/97-007r2/pdf/97-007r2.pdf) :
12.4.1.6 Restrictions on entities associated with dummy arguments
While an entity is associated with a dummy argument, the following restrictions hold:
(1) No action that affects the allocation status of the entity may be taken. Action that affects the value of the entity or any part of it shall be taken through the dummy argument unless...
Thus, given the heading SUBROUTINE SUB(A, B), when some parts of A or B or both A and B get changed in the subroutine, CALL SUB(C, C) is forbidden. The clauses following the 'unless...' affect POINTER and TARGET variables, which are excluded from this post.
If we refer to this as the Fortran Anti Aliasing Rule (FAAR), the following is a summary of the status-quo regarding programs that violate the FAAR.
The Fortran Standard's stance: A program that violates the FAAR is 'non-conforming', and the results of running such a non-conforming program are 'undefined'. A compiler is not required to detect such violations.
The present status:
Old mainframes and early PC Fortran compilers did only simple optimizations, and programs that violated the FAAR rule worked as intended most of the time, so the violations went undetected for years. Current compilers do more sophisticated optimizations, and those programs fail often (by producing wrong results).
Optimizing compilers such as Gfortran and IFort provide options to ratchet down the optimizations in order to let such programs work as intended, but they do not provide assistance to the programmer to locate and fix the CALLs that violate the FAAR. Early versions of G77 did, with the -falias-check option, but that option was withdrawn when GCC 2.8 stopped supporting the option.
My reasons to ask for a new feature: Programs that violate FAAR exist, although they are not widespread. It can even happen that with a medium size or large program, written today, a small change to a program can introduce a violation of FAAR where none existed before. When a violation occurs, it is very difficult and time-consuming to isolate the violation.
In the most recent instance where I faced this problem, I was using the ENLSIP least squares package (see https://forums.silverfrost.com/Forum/Topic/3083 ). It consists of 110 subprograms. I used FSPLIT to split apart each subprogram to a separate file. I compiled all the files with Gfortran -O0 and ran the resulting program to establish the baseline. I then compiled each of the 110 files with -O2, one at a time, followed by linking and running, until I found one file that caused the results to be different (my luck, problem present in only one subprogram). At this point I stopped and investigated whether undefined variables, subscript violations or mismatched subroutine calls could be culprits. I found a few such errors and fixed those. At this point, I remembered 'aliasing', and looked for subroutine calls with duplicated actual arguments. There was only one. I tried fixing that by enclosing the second instance of the duplicated argument in parentheses. That worked with Gfortran, but failed with FTN95 because of a bug (which, Paul says, has been fixed).
Thus, my request: Please provide a /CheckAliasedArg (or similar name) compiler option to detect subprogram calls with aliased arguments. Such a check would greatly add to the impressive error-checking capabilities of FTN95.
It will probably be necessary to have both static (compile time) and dynamic (run time) components of this check. The static check could issue warnings and the dynamic check could abort with traceback.
Thanks to Paul Laidler for encouraging me to make this request.