Spurious warning about dummy arguments for pure functions

Spurious warning about dummy arguments for pure functions

Imagen de IanH

The following extract:

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

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

[U:projectsIFort 13.0 testPureFunctionWarning]
>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)
-------------------------^
[U:projectsIFort 13.0 testPureFunctionWarning]
>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)
-------------------------^

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

publicaciones de 5 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.
Imagen de Steve Lionel (Intel)

Thanks, we'll take a look.

Steve
Imagen de IanH

Did you come to any conclusion about the validity of this warning?

Imagen de Steve Lionel (Intel)

The warning is not valid. I have escalated this to development as issue DPD200236930. Thanks for the nice example/

Steve
Imagen de Steve Lionel (Intel)

This is fixed for a release later this year.

Steve

Inicie sesión para dejar un comentario.