ICE on assignment with elemental function

Compiling the valid Fortran source code below, the nvfortran compiler (version 21.3) crashes with internal compiler error. Also the warning printed before the crash is somewhat dubious.

nvfortran ~/dftb_devel/dftbplus/bug2.f90 
NVFORTRAN-W-0310-Unsafe fixed-length string temporary*500 being used  (/home/aradi/dftb_devel/dftbplus/bug2.f90: 54)
NVFORTRAN-F-0000-Internal compiler error. Deferred-length character symbol must have descriptor     689  (/home/aradi/dftb_devel/dftbplus/bug2.f90: 54)
NVFORTRAN/x86-64 Linux 21.3-0: compilation aborted
module testmod1
  implicit none

  public :: tolower


  !> Returns a lowercase string
  elemental function tolower(str) result(lower)

    !> String to convert to lowercase
    character(len=*), intent(in) :: str

    !> Lowercase string
    character(len=len(str)) :: lower

    integer :: ii, iTmp

    do ii = 1, len(str)
      iTmp = iachar(str(ii:ii))
      if (65 <= iTmp .and. iTmp <= 90) then
        lower(ii:ii) = achar(iTmp + 32)
        lower(ii:ii) = str(ii:ii)
      end if
    end do

  end function tolower

end module testmod1

module testmod2
  use testmod1, only : tolower
  implicit none

  public :: TSelector, setItems, showItems

  type :: TSelector
    character(:), allocatable :: selection(:)
  end type TSelector


  subroutine setItems(selector, items)
    class(TSelector), intent(inout) :: selector
    character(*), intent(in) :: items(:)

    selector%selection = tolower(items)

  end subroutine setItems

  subroutine showItems(selector)
    class(TSelector), intent(inout) :: selector

    integer :: ii
    do ii = 1, size(selector%selection)
      print *, ii, trim(selector%selection(ii))
    end do

  end subroutine showItems

end module testmod2

program testprog
  use testmod2, only : TSelector, setItems, showItems
  implicit none

  type(TSelector) :: selector

  call setItems(selector, [character(2) :: "Si", "C"])
  call showItems(selector)

end program testprog

Thanks baradi66259,

I was able to reproduce the error here and have filed a problem report, TPR #29960.