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

Spurious warning about dummy arguments for pure functions

IanH
Honored Contributor III
699 Views

The following extract:

[fortran]

MODULE PureFunctionWarning
  IMPLICIT NONE
 
  PRIVATE
 
  INTERFACE ToValue
    MODULE PROCEDURE ToValue_int
  END INTERFACE ToValue
 
  CHARACTER(*), PARAMETER :: fmt_tovalue = "('(G',I0,'.0)')"  
CONTAINS  
  ELEMENTAL SUBROUTINE ToValue_int(str, val, ierr)    
    !---------------------------------------------------------------------------
    CHARACTER(*), INTENT(IN) :: str
    INTEGER, INTENT(OUT) :: val
    INTEGER, INTENT(OUT) :: ierr
    !---------------------------------------------------------------------------
    CHARACTER(10) :: fmt_string
    !***************************************************************************
    WRITE (fmt_string, fmt_tovalue) LEN(str)
    READ (str, fmt_string, IOSTAT=ierr) val
  END SUBROUTINE ToValue_int  
    
  PURE FUNCTION len_fmt3(str) RESULT(l)
    !---------------------------------------------------------------------------
    CHARACTER(*), INTENT(IN) :: str
    INTEGER :: l
    !---------------------------------------------------------------------------
    INTEGER :: stat
    !***************************************************************************
    CALL ToValue(str, l, stat)        ! Call via the generic - get warning.
    ! CALL ToValue_int(str, l, stat)  ! Cal the specific - no warning.
    IF (stat /= 0) l = 0
  END FUNCTION len_fmt3  
END MODULE PureFunctionWarning
[/fortran]

when compiled with 13.0.0.089, gives warnings which I think are bogus, noting the generic/specific comments above.

[plain]


>ifort /c /check:all /warn:all /stand:f03 /standard-semantics PureFunctionWarning.f90
Intel(R) Visual Fortran Compiler XE for applications running on IA-32, Version 13.0.0.089 Build 20120731
Copyright (C) 1985-2012 Intel Corporation.  All rights reserved.

PureFunctionWarning.f90(24): warning #7363: Standard F2003 does not allow a dummy argument to a pure function to be used
 in a variable definition context.   [STR]
  PURE FUNCTION len_fmt3(str) RESULT(l)
-------------------------^


>ifort /c /check:all /warn:all /stand:f95 /standard-semantics PureFunctionWarning.f90
Intel(R) Visual Fortran Compiler XE for applications running on IA-32, Version 13.0.0.089 Build 20120731
Copyright (C) 1985-2012 Intel Corporation.  All rights reserved.

PureFunctionWarning.f90(24): warning #7363: Standard F95 does not allow a dummy argument to a pure function to be used i
n a variable definition context.   [STR]
  PURE FUNCTION len_fmt3(str) RESULT(l)
-------------------------^

[/plain]

(The plain syntax highlighter is eating backslash characters.  The Fortran syntax highighter appears to have run out of paint brushes.)

0 Kudos
4 Replies
Steven_L_Intel1
Employee
699 Views
Thanks, we'll take a look.
0 Kudos
IanH
Honored Contributor III
699 Views
Did you come to any conclusion about the validity of this warning?
0 Kudos
Steven_L_Intel1
Employee
699 Views
The warning is not valid. I have escalated this to development as issue DPD200236930. Thanks for the nice example/
0 Kudos
Steven_L_Intel1
Employee
699 Views

This is fixed for a release later this year.

0 Kudos
Reply