/CHECK_ALIAS compiler option


/CHECK_ALIAS can be used with /CHECK (or options such as /CHECKMATE that imply /CHECK) in order to provide runtime checking for aliased arguments. When used without /CHECK it has no effect.

Note 12.21 of the Fortran 95 Standard states:

"If there is a partial or complete overlap between the actual arguments associated with two different dummy arguments of the same procedure and the dummy arguments have neither the POINTER nor TARGET attribute, the overlapped portions shall not be defined, redefined, or become undefined during the execution of the procedure."

This restriction is rarely needed but may be required by compilers that produce highly optimised code.

Illustrations of code that fail this requirement are provided in the Polyhedron diagnostic test suite.

Here is the source code for alias1.for in the Polyhedron suite:

program alias1
 x = 1.0 
 call sub(x,x)
 print *,x 
subroutine sub(x,y)

This code fails first at "x=2." because x overlaps y for this call to sub.

Here is the source code for alias2.for in the Polyhedron suite:

program alias2
 real x(10)
 do i =1,10
   x(i) = i 
 call sub(x(1),x(5))
 print * ,x
subroutine sub(x,y)
 real x(*) , y(*)
 y(1) = 0
 x(10) = 0

This code fails at "y(1) = 0." because y overlaps x for this call to sub.

FTN95 detects these and similar errors at runtime when using /CHECK_ALIAS combined with /CHECK.

FTN95 can be configured (using /CONFIG) to make /CHECK_ALIAS the default. When configured, /CHECK_ALIAS will always be included when /CHECK is used.



Copyright © 1999-2023 Silverfrost Limited