Ifx does not compile this function declaration form

The code below compiles and runs with lfortran, gfortran, and g95

module m
implicit none
contains
pure character(len=len(s)) function to_lower(s)
!      pure function to_lower(s)
character(len=*), intent(in) :: s
!         character(len=len(s)) :: to_lower
integer :: i, k
do i = 1, len(s)
k = iachar(s(i:i))
if (k >= iachar(“A”) .and. k <= iachar(“Z”)) then
to_lower(i:i) = achar(k + 32)
else
to_lower(i:i) = s(i:i)
end if
end do
end function to_lower
end module m

program main
use m
implicit none
print “(a)”, to_lower("ABcD123/")
end program main

but ifx says

c:\python\fortran>ifx xto_lower.f90
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2025.0.4 Build 20241205
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.

xto_lower.f90(4): error #6362: The data types of the argument(s) are invalid.   [LEN]
pure character(len=len(s)) function to_lower(s)
-----------------------------^
xto_lower.f90(6): error #6415: This name cannot be assigned this data type because it conflicts with prior uses of the name.   [S]
character(len=), intent(in) :: s
-----------------------------------------^
xto_lower.f90(6): error #9020: Redeclaration of implicitly-declared character string must have a constant length.   [S]
character(len=), intent(in) :: s
-----------------------------------------^
xto_lower.f90(21): error #7013: This module file was not generated by any release of this compiler.   [M]
use m
----^
xto_lower.f90(23): error #6404: This name does not have a type, and must have an explicit type.   [TO_LOWER]
print “(a)”, to_lower("ABcD123/")
-------------^
compilation aborted for xto_lower.f90 (code 1)

ifx compiles it if the commented out lines replace the first line of function to_lower

ping @greenrongreen

1 Like

This is akin to an issue I wrote about a couple of weeks ago. The dummy argument s is referenced before it is actually declared.

1 Like

The compiler is justified in rejecting this usage. Compilers that accept it should issue a message notifying the user of an extension to the Fortran Standard.

10.1.11 Specification expression, para 6

A variable in a specification expression shall have its type and type parameters, if any, specified by a previous declaration in the same scoping unit, by the implicit typing rules in effect for the scoping unit, or by host or use association. If a variable in a specification expression is typed by the implicit typing rules, its appearance in any subsequent type declaration statement shall confirm the implied type and type parameters. If a specification inquiry depends on the type of an object of derived type, that type shall be previously defined.

3 Likes

He works for NVIDIA now, not Intel.

1 Like

The capability of CONTAINS is certainly unusual given the approach required for 10.1.11