[Bug fortran/91544] New: When initializing allocatable character array get "Error: size of variable 'A.0' is too large"
urbanjost at comcast dot net
gcc-bugzilla@gcc.gnu.org
Sun Aug 25 23:03:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91544
Bug ID: 91544
Summary: When initializing allocatable character array get
"Error: size of variable 'A.0' is too large"
Product: gcc
Version: 7.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: urbanjost at comcast dot net
Target Milestone: ---
If use a non-constant integer as the length for an allocatable character
variable array get a confusing error message.
If the integer LINE_LENGTH is a PARAMETER it works.
A work-around where the array is first allocated as a zero-size array
and then included in the assignment works.
Otherwise get an odd compile-time error about "A.0" being too large.
program testit
implicit none
integer :: line_length=50
character(len=:),allocatable :: test_in(:)
#ifdef BAD
test_in=[ character(len=line_length) :: 'aaa','bb' ]
#else
allocate(character(len=line_length) :: test_in(0))
test_in=[character(len=line_length) :: test_in,'aaa','bb']
#endif
write(*,*)test_in
end program testit
gfortran -UBAD xx.F90
aaa bb
gfortran -DBAD xx.F90
xx.f90:4:0:
test_in=[ character(len=line_length) :: 'this is a test' ]
Error: size of variable 'A.0' is too large
More information about the Gcc-bugs
mailing list