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

--- Comment #2 from anlauf at gcc dot gnu.org ---
Update: at r15-2986 the allocation errors are no longer present.
Likely fixed by r15-1704 and r15-2910.  Older branches are still affected.

Replacing mold= by source=, or using parentheses around polymorphic mold
argument we hit issues with the ALLOCATE statement:

MODULE mold_test_mo
  IMPLICIT NONE
CONTAINS
  SUBROUTINE aalloc(sample)
    CLASS(*),INTENT(in) :: sample
    INTEGER :: localsample
    CLASS(*),ALLOCATABLE :: arr(:), tmparr(:)

!   ALLOCATE(arr(1), mold=sample)
    ALLOCATE(arr(1), source=sample)
    CALL MOVE_ALLOC(arr, tmparr)
    SELECT TYPE(tmparr)
    TYPE is (INTEGER)
       PRINT *,tmparr
    END SELECT
!   ALLOCATE(arr(2), mold=tmparr(1))   ! OK
!   ALLOCATE(arr(2), mold=(tmparr(1))) ! ICE
    ALLOCATE(arr(2), source=tmparr(1)) ! runtime segfault
    SELECT TYPE(arr)
    TYPE is (INTEGER)
       PRINT *,arr
    END SELECT
  END SUBROUTINE aalloc
END MODULE mold_test_mo

PROGRAM mold_test
  USE mold_test_mo
  IMPLICIT NONE
  CALL aalloc(3)
END PROGRAM mold_test

Reply via email to