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

            Bug ID: 67977
           Summary: allocatable strings, array section reallocated -
                    non-standard behaviour
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mexas at bristol dot ac.uk
  Target Milestone: ---

character(:), allocatable :: z
z = "cockatoo"
write (*,*) z, len(z)
z(:) = ''
write (*,*) z, len(z)
end

with gfortran 4.9 to 6.0 this returns:

 cockatoo           8
            0

which is wrong. It should return:

 cockatoo           8
                    8

i.e. the length of variable "z" must not change
from the second assignment statement. This is because
the array section is used ( z(:) ), which should not
trigger reallocation. So "z" after the second assignment
must still be 8 characters long, all blanks.

Anton

Reply via email to