[J3] [SC22WG5.6611] INTENT part of Explicit Interface?

Steve Lionel steve at stevelionel.com
Sun Sep 22 14:44:53 UTC 2024


On 9/22/2024 9:08 AM, Klemm, Michael via J3 wrote:
> I have another question about INTENT attributes.  Are they part of the visible interface of a subroutine or are they only visible inside the subroutine?  I'm asking this to understand if adding INTENT(IN) to a dummy argument of an existing subroutine is a breaking change or not.

Argument intent is a characteristic of a dummy data object (15.3.2.2) 
and thus if the intent declared in the procedure differs from an 
explicit interface provided to the caller, that is a conflict and some 
compilers may complain about it. Example:

implicit none
interface
   subroutine sub (x)
   real :: x ! INTENT omitted
   end subroutine sub
end interface
real :: y = 3.0
call sub(y)
end

subroutine sub (x)
real, intent(IN) :: x ! INTENT added
print *, x
end subroutine sub

D:\Projects>ifx /warn:interface t.f90
Intel(R) Fortran Compiler for applications running on Intel(R) 64, 
Version 2024.2.1 Build 20240711
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.

t.f90(4): error #8000:  There is a conflict between local interface 
block and external interface block.   [X]
   subroutine sub (x)
------------------^

D:\Projects>nagfor -c t.f90
NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7206
Error: t.f90: Inconsistent INTERFACE block for procedure SUB from TEST
        Argument X (no. 1) has a different INTENT

Steve



More information about the J3 mailing list