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

            Bug ID: 67988
           Summary: ICE on accessing substring with negative range in
                    array constructor
           Product: gcc
           Version: 5.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gerhard.steinmetz.fort...@t-online.de
  Target Milestone: ---

Accessing a correctly declared character with negative substring-
range (len < -1) e.g. inside of an array constructor (temp array)
requests memory of about 2^64 (= 18446744073709551616) :


$ cat z1.f90
program p
   character(3), parameter :: c = 'abc'
   character(3) :: x(1)
   x = c(:-2)
   x = [ c(:-2) ]
end


$ gfortran -g -O0 -Wall -fcheck=all -fno-frontend-optimize z1.f90
f951: out of memory allocating 18446744073709551612 bytes after a total of
434176 bytes

---

With len = -1 :

$ cat z3.f90
program p
   character(3), parameter :: c = 'abc'
   character(3) :: x(1)
   x = c(:-1)
   x = [ c(:-1) ]
   print *, x
end

$ gfortran -g -O0 -Wall -fcheck=all -fno-frontend-optimize z3.f90
$ a.out

$ gfortran z3.f90
$ a.out
 ?

---

Maybe related to pr67987.

Reply via email to