Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Specification expressions, DIMENSION ordering and a mischievous user

$
0
0

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

 

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>