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

            Bug ID: 107872
           Summary: ICE on recursive DT with DTIO
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jwmwalrus at gmail dot com
  Target Milestone: ---

Hi.

The code below throws the following ICE:

$ gfortran -c -fbacktrace test2.f90 
gfortran: internal compiler error: Segmentation fault signal terminated program
f951
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See <file:///usr/share/doc/gcc-12/README.Bugs> for instructions.

----------8<----------
module mod1
    type t
        integer :: data
        type(t), allocatable :: next
    contains
        procedure, private :: write_t
        generic :: write(formatted) => write_t
    end type
contains
    recursive subroutine write_t(this, unit, iotype, v_list, iostat, iomsg)
        class(t), intent(in) :: this
        integer, intent(in) :: unit
        character(*), intent(in) :: iotype
        integer, intent(in) :: v_list(:)
        integer, intent(out) :: iostat
        character(*), intent(inout) :: iomsg
        if (ALLOCATED(this%next)) &
            write (unit, '(dt)') this%next
    end subroutine
end module
---------->8----------


$ gfortran --version
GNU Fortran (Debian 12.2.0-9) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Reply via email to