https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59345

--- Comment #3 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> 
---
I'm pasting here another testcase, since I think it is related. 

This works as it should (i.e. no pack/unpack), an allocatable as function
result:

> cat tt.f90
SUBROUTINE S1(A)
 INTERFACE
   FUNCTION CONTIGUOUS_F1() RESULT(res)
    INTEGER, ALLOCATABLE :: res(:)
   END FUNCTION
 END INTERFACE
 CALL S2(CONTIGUOUS_F1())
END SUBROUTINE

This generates a pack/unpack as well, i.e. an array that is a function result:

> cat tt.f90
SUBROUTINE S1(A)
 INTERFACE
   FUNCTION CONTIGUOUS_F1() RESULT(res)
    INTEGER :: res(5)
   END FUNCTION
 END INTERFACE
 CALL S2(CONTIGUOUS_F1())
END SUBROUTINE

This also leads to a pack, a function that returns an allocatable, but called
via a procedure pointer.

> cat tt.f90
SUBROUTINE S1(A)
 INTERFACE
   FUNCTION CONTIGUOUS_F1() RESULT(res)
    INTEGER, ALLOCATABLE :: res(:)
   END FUNCTION
 END INTERFACE
 PROCEDURE(CONTIGUOUS_F1), POINTER :: A
 CALL S2(A())
END SUBROUTINE


In these cases, the issue seems that gfc_is_simply_contiguous returns false,
while maybe it should return true ?

I think this is also the reason things go wrong with the testcase in comment
#1, this is an EXPR_OP, and somehow might be simply_contiguous nevertheless.

Reply via email to