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

            Bug ID: 86545
           Summary: [6/7/8/9 Regression] ICE in transfer_expr on invalid
                    WRITE statement
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: janus at gcc dot gnu.org
  Target Milestone: ---

Test case:


module m

   type tString
      character(len=:), allocatable :: cs
   end type

   interface my_trim
      module procedure trim_string
   end interface

contains

   elemental function trim_string(self) result(str)
      type(tString) :: str
      class(tString), intent(in) :: self
   end function

end module


program p

   use m

   type(tString) :: s

!    write(*,*) trim_string(s)   ! correctly rejected
   write(*,*) my_trim(s)         ! ICE

end


This invalid code gives an ICE with all recent gfortran versions (4.9 up to
trunk). On trunk the backtrace looks like this:


    write(*,*) my_trim(s)         ! ICE

internal compiler error: in transfer_expr, at fortran/trans-io.c:2399
0x7908d0 transfer_expr
        /home/janus/gcc/trunk/gcc/fortran/trans-io.c:2399
0x79027f transfer_expr
        /home/janus/gcc/trunk/gcc/fortran/trans-io.c:2496
0x792eb2 gfc_trans_transfer(gfc_code*)
        /home/janus/gcc/trunk/gcc/fortran/trans-io.c:2664
0x71cce7 trans_code
        /home/janus/gcc/trunk/gcc/fortran/trans.c:2044
0x78f8d0 build_dt
        /home/janus/gcc/trunk/gcc/fortran/trans-io.c:2027
0x71cd07 trans_code
        /home/janus/gcc/trunk/gcc/fortran/trans.c:2016
0x751925 gfc_generate_function_code(gfc_namespace*)
        /home/janus/gcc/trunk/gcc/fortran/trans-decl.c:6469
0x6d0860 translate_all_program_units
        /home/janus/gcc/trunk/gcc/fortran/parse.c:6125
0x6d0860 gfc_parse_file()
        /home/janus/gcc/trunk/gcc/fortran/parse.c:6328
0x719b4f gfc_be_parse_file
        /home/janus/gcc/trunk/gcc/fortran/f95-lang.c:204



gfortran 4.8 rejects it without ICE:

      character(len=:), allocatable :: cs
                                         1
Error: Deferred-length character component 'cs' at (1) is not yet supported


So, technically the ICE is a regression.

Reply via email to