https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95038
Bug ID: 95038 Summary: Not treating function result name as a variable. Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: longb at cray dot com Target Milestone: --- Original test case from user: > cat test.f90 real(4) function x (a) real(kind(x)) a(:) interface if1 subroutine sub (a) real(kind(x)) a(:) end subroutine sub end interface if1 x = 0 end function x > cat test1.f90 function x (a) result(res) real(4) :: res real(kind(res)) a(:) interface if1 subroutine sub (a) real(kind(res)) a(:) end subroutine sub end interface if1 res = 0 end function x Second alternate test case: > cat test2.f90 real(4) function x (a) real(kind(x)) a(:) interface if1 subroutine sub (a) import :: x real(kind(x)) a(:) end subroutine sub end interface if1 x = 0 end function x Second alternate test case: > cat test2.f90 real(4) function x (a) real(kind(x)) a(:) interface if1 subroutine sub (a) import :: x real(kind(x)) a(:) end subroutine sub end interface if1 x = 0 end function x The original test.f90 and test1.f90 arguable need an IMPORT statement in the interface. However: > gfortran -c test2.f90 > gfortran -c test1.f90 > gfortran -c test.f90 test.f90:5:28: 5 | real(kind(x)) a(:) | 1 Error: 'x' argument of 'kind' intrinsic at (1) must be a data entity test2 (the one with the IMPORT) compiles. But test1, without an IMPORT, fails to compile. It seems that gfortran is failing to recognize that the function name, when no RESULT clause is specified , is the name of a local variable.