[Bug fortran/70752] New: Incorrect LEN for ALLOCATABLE CHARACTER
gilbert.scott at easynet dot co.uk
gcc-bugzilla@gcc.gnu.org
Thu Apr 21 12:08:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70752
Bug ID: 70752
Summary: Incorrect LEN for ALLOCATABLE CHARACTER
Product: gcc
Version: 5.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: gilbert.scott at easynet dot co.uk
Target Milestone: ---
$ gfortran --version
GNU Fortran (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
$ cat test.f95
PROGRAM TEST
IMPLICIT NONE
INTEGER, PARAMETER :: I = 3
TYPE T
CHARACTER(LEN=:), ALLOCATABLE :: C(:)
END TYPE T
TYPE(T), TARGET :: S
CHARACTER (LEN=I), POINTER :: P(:)
ALLOCATE ( CHARACTER(LEN=I) :: S%C(5) )
PRINT *, 'SIZE(S%C) = ',SIZE(S%C)
PRINT *, 'LEN(S%C) = ',LEN(S%C)
P => S%C
END PROGRAM TEST
$ gfortran -Wall -fbounds-check test.f95 -o test
$ ./test
SIZE(S%C) = 5
LEN(S%C) = 0
At line 14 of file test.f95
Fortran runtime error: Unequal character lengths (3/0) in pointer assignment
? Why does the LEN function return zero?
The SIZE function is correct.
LEN(S%C(1)) gives the correct result, but LEN should work with an array
argument too.
? Why does the pointer assignment fail?
It is OK without -fbounds-check.
More information about the Gcc-bugs
mailing list