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

            Bug ID: 63469
           Summary: Automatic reallocation of allocatable scalar length
                    even when substring implicitly specified
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: davidgkinniburgh at yahoo dot co.uk

CHARACTER(:), ALLOCATABLE :: s

ALLOCATE (character(32) :: s)

s(1:32) = 'string'
print *, 'Length of ', s, ' with substring = ', LEN(s)

s(:) = 'string'
print *, 'Length of ', s, ' with substring = ', LEN(s)

s = 'string'
print *, 'Length of ', s, ' without substring = ', LEN(s)


gfortran (4.9.1 and earlier) gives:

 Length of string                           with substring =           32
 Length of string with substring =            6
 Length of string without substring =            6


IVF (15.0) gives:

 Length of string                           with substring =           32
 Length of string                           with substring =           32
 Length of string without substring =            6

which I think is correct.

It is the implicit definition of both the beginning and the ending of 's' that
seems to do the damage.

Reply via email to