llvm-project
llvm-project copied to clipboard
[Flang] Possible incorrect semantics check on function result?
Small reproducer is below:
module testing
contains
subroutine foo(func)
interface
function func(p) result (res)
REAL, DIMENSION(:) :: p
REAL, DIMENSION(size(p)) :: res
end function
end interface
end subroutine
function bar(p) result(res)
REAL, DIMENSION(:) :: p
REAL, DIMENSION(size(p)) :: res
end function
end module
program test
use testing
call foo(bar)
end program
I think this is valid Fortran (but I am not 100% sure) and gfortran and ifort both accept it (https://godbolt.org/z/Mr6v7To9e) but I am seeing the following error with flang:
error: Semantic errors in red_test.f90
./red_test.f90:20:12: error: Actual procedure argument has interface incompatible with dummy argument 'func=': function results have distinct extents
call foo(bar)
^^^
Changing the check here to use !ShapesAreCompatible rather than the != operator seems to allow this to pass, but I'm not sure if this breaks other things yet/if this a coincidental "fix" (and assuming the source code above is valid).
@llvm/issue-subscribers-flang-frontend
Fixed by c1a77839cc99!