Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29262 Discussions

Specification expressions, DIMENSION ordering and a mischievous user

IanH
Honored Contributor III
621 Views

With ifort 16.0 Build 20151021 (that's update 1, I think) this program prints `1 2`.  That doesn't make much sense - I think a strict reading of the standard suggests the program is conforming (noting that the marked line does not result in a reference to either the value of an element of `a` or depend on an array bound of `a`) and the output should be `2 2` (which is what current gfortran does). 

Failing that it might be standard interp territory.  Either way... enjoy!

  MODULE SillyModule
    IMPLICIT NONE
    PRIVATE
    PUBLIC :: Silly
    INTERFACE Silly
      MODULE PROCEDURE Silly_scalar
      MODULE PROCEDURE Silly_array
    END INTERFACE Silly
  CONTAINS
    PURE FUNCTION Silly_scalar(a) RESULT(r)
      INTEGER, INTENT(IN) :: a
      INTEGER :: r
      r = 1
    END FUNCTION Silly_scalar
    
    PURE FUNCTION Silly_array(a) RESULT(r)
      INTEGER, INTENT(IN) :: a(:)
      INTEGER :: r
      r = 2
    END FUNCTION Silly_array
  END MODULE SillyModule

  PROGRAM JustToCauseTrouble
    USE SillyModule
    IMPLICIT NONE
    CALL sub([1,2])
  CONTAINS
    SUBROUTINE sub(a)
      INTEGER :: a
      INTEGER :: x(Silly(a))      ! ####
      DIMENSION :: a(2)
      PRINT *, SIZE(x), Silly(a)
    END SUBROUTINE sub
  END PROGRAM JustToCauseTrouble


 

 

0 Kudos
1 Reply
Steven_L_Intel1
Employee
621 Views

Thanks, we'll check it out.

0 Kudos
Reply