This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/45197] New: [F2008] Allow IMPURE elemental procedures


In Fortran 2008, an ELEMENTAL procedure needs not necessarily be PURE. 
Procedures can now be specified to be IMPURE, and if this is applied to an
ELEMENTAL procedure it is not automatically PURE as it otherwise is.

For instance, the following code will fill b(n) with cumulative sum of elements
in array element order and thus print (/ 1, 3, 6, 10, 15 /):

PROGRAM main
  IMPLICIT NONE

  INTEGER, PARAMETER :: n = 5
  INTEGER :: i
  REAL :: a(n), b(n), s

  a = (/ (i, i = 1, n) /)
  s = 0.0
  b = accumulate (a, s)

  PRINT *, b

CONTAINS

  IMPURE ELEMENTAL FUNCTION accumulate (a, s)
    REAL, INTENT(IN) :: a
    REAL, INTENT(INOUT) :: s
    REAL :: accumulate

    s = s + a
    accumulate = s
  END FUNCTION accumulate

END PROGRAM main


-- 
           Summary: [F2008] Allow IMPURE elemental procedures
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: domob at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45197


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]