There is definitely a bug here or better as @FortranFan said its implementation in gfortran is not complete yet. However, there is a walkaround but not the exact solution you would expect.

In short: you cannot have both allocatable: the internal array and the PDT (parameterized derived type) and actually the latter case I couldnât make it work.

The following module is common for both the following examples:

```
module m_matrix
implicit none
type :: t_matrix(rows, k)
integer, len :: rows
integer, kind :: k
real(kind = k):: values(rows) ! note that I am not declaring it here as allocatable!!!
end type
end module m_matrix
```

First (working) example with an allocatable internal array (link):

```
program test_matrix
use iso_fortran_env, only:real32
use m_matrix
implicit none
type(t_matrix(k=real32,rows=:)), allocatable :: m
integer :: dims, i
dims = 10
allocate(t_matrix(k=real32, rows=dims) :: m)
m%values = [(i*1., i = 1, dims)]
print*, m%values
end program test_matrix
```

Second (non-working) example with allocatable PDT (link):

```
program test_matrix
use iso_fortran_env, only:real32
use m_matrix
implicit none
integer, parameter :: rr = 5
type(t_matrix(k=real32, rows=rr)), allocatable :: m(:)
integer :: dims, i
dims = 10
allocate(m(dims)) ! Program compiles until here provided
! the below lines are commented, and I have no idea why it does so.
! but if you try to access the allocated memory, as I do below, it throws a
! segmentation fault (see link above)
!do i = 1, dims
! m(i)%values = 0.
! print*,m(i)%values
!end do
end program test_matrix
```

Even with the first working example, if I am being honest, I am not sure why it compiles or if it should.

ps1. Regarding the second case, I also tried to wrap the t_matrix in another derived type but not matter what I tried I was getting the same error.

ps2. Regardless of the current state of PDT, I personally never found a good reason to use them, nothing I cannot code with a simple DT, and since most times the parameters are known at run time this feature as it is, is just useless. Also, the parameter `integer, kind :: k`

must always be known at compile-time, which is what really matters for me. Of course, if that wasnât the case then we would be talking about the first template feature of Fortran.