[Bug fortran/67977] New: allocatable strings, array section reallocated - non-standard behaviour
mexas at bristol dot ac.uk
gcc-bugzilla@gcc.gnu.org
Thu Oct 15 18:55:00 GMT 2015
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
More information about the Gcc-bugs
mailing list