gcc/testsuite/gfortran.dg/allocate_with_mold_3.f90
raw| 1 | ! { dg-do run } |
| 2 | ! PR fortran/89174 - this used to segfault on execution. |
| 3 | ! Test case by Neil Carlson. |
| 4 | module mod |
| 5 | type :: array_data |
| 6 | class(*), allocatable :: mold |
| 7 | contains |
| 8 | procedure :: push |
| 9 | end type |
| 10 | contains |
| 11 | subroutine push(this, value) |
| 12 | class(array_data), intent(inout) :: this |
| 13 | class(*), intent(in) :: value |
| 14 | allocate(this%mold, mold=value) ! <== SEGFAULTS HERE |
| 15 | end subroutine |
| 16 | end module |
| 17 | |
| 18 | use mod |
| 19 | type(array_data) :: foo |
| 20 | call foo%push(42) |
| 21 | end |