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

            Bug ID: 70815
           Summary: ICE when using read statement applied to
                    deferred-length string pointer as derived type
                    component
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pvdp.bugzilla at gmail dot com
  Target Milestone: ---

Read statements applied to deferred-length string pointers inside derived types
cause an ICE if upper bound is omitted.

EXAMPLE:

program mwe

implicit none

type tStruc
    character(len=:),pointer :: str
end type tStruc


type(tStruc) :: t
character(len=300),target :: buffer
character(len=:),pointer :: strptr
integer :: i, j, k

buffer = "10 11 12"
t%str => buffer
strptr => buffer


read(t%str(3:),*) j             ! <-- causes ICE
read(t%str(3:len(t%str)),*) j   ! <-- work-around

read(buffer(3:),*) i     ! works
read(strptr(3:),*) k     ! works

print *, i,j,k

end program

ICE REPORT MINGW:

f951.exe: out of memory allocating 1718048288 bytes

ICE REPORT LINUX:

f951: internal compiler error: Segmentation fault
0xa3e2ef crash_signal
        ../../src/gcc/toplev.c:383
0x5f375e gfc_copy_shape(__mpz_struct (*) [1], int)
        ../../src/gcc/fortran/expr.c:708
0x5f3805 gfc_copy_expr(gfc_expr*)
        ../../src/gcc/fortran/expr.c:393
0x64dbb7 gfc_resolve_substring_charlen(gfc_expr*)
        ../../src/gcc/fortran/resolve.c:4575
0x64b555 gfc_resolve_expr(gfc_expr*)
        ../../src/gcc/fortran/resolve.c:6262
0x612926 gfc_resolve_dt(gfc_dt*, locus*)
        ../../src/gcc/fortran/io.c:2915
0x652967 gfc_resolve_code(gfc_code*, gfc_namespace*)
        ../../src/gcc/fortran/resolve.c:10375
0x654932 resolve_codes
        ../../src/gcc/fortran/resolve.c:15057
0x654a21 gfc_resolve(gfc_namespace*)
        ../../src/gcc/fortran/resolve.c:15091
0x6402ba resolve_all_program_units
        ../../src/gcc/fortran/parse.c:5282
0x6402ba gfc_parse_file()
        ../../src/gcc/fortran/parse.c:5525
0x67f9d5 gfc_be_parse_file
        ../../src/gcc/fortran/f95-lang.c:229
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.

Reply via email to