On Mon, Oct 28, 2024 at 06:00:18PM +0900, Kazuyoshi Furutaka wrote: > Dear gfortran experts... > > The attached program runs OK, but `ptype`ing using gdb > on the deferred-length character array returns empty(?) > result, as the following (the results for integer and > real arrays are correct ): > > (gdb) ptype intarr > type = integer(kind=4), allocatable (8) > (gdb) ptype realarr > type = real(kind=8), allocatable (8) > (gdb) ptype chararr > type = Type > End Type > > Is this a bug? >
Likely, yes. Not sure if it's a GCC or GDB bug. File a bug report in gcc's bugzilla. Dynamic allocation of a scalar deferred-length variable works. program arrays character(len=:), allocatable :: chararr chararr="ahoaho" print *, chararr end program arrays Breakpoint 1, arrays () at a.f90:4 4 chararr="ahoaho" (gdb) n 5 print *, chararr (gdb) p chararr $1 = (PTR TO -> ( character*(*) )) 0x201008020 (gdb) p *chararr $2 = 'ahoaho' Static memory works. program arrays character(len=6) :: chararr(2) chararr="ahoaho" print *, chararr end program arrays Breakpoint 1, arrays () at a.f90:18 18 chararr="ahoaho" (gdb) n 19 print *, chararr (gdb) p chararr $1 = ('ahoaho', 'ahoaho') (gdb) p &chararr $2 = (PTR TO -> ( character*6 (2) )) 0x7fffffffe614 Dynamic allocation of an array of fixed length strings works. program arrays character(len=6), allocatable :: chararr(:) allocate(chararr(2)) chararr="ahoaho" print *, chararr end program arrays Breakpoint 1, arrays () at a.f90:32 32 chararr="ahoaho" (gdb) n 33 print *, chararr (gdb) p chararr $1 = ('ahoaho', 'ahoaho') (gdb) p &chararr $2 = (PTR TO -> ( character*6, allocatable (2) )) 0x201016000 Your testcase of allocation of an array of deferred-length string strings. program arrays character(len=:), allocatable :: chararr(:) allocate(character(len=6) :: chararr(2)) chararr="ahoaho" print *, chararr end program arrays Breakpoint 1, arrays () at a.f90:53 53 chararr="ahoaho" (gdb) n 54 print *, chararr (gdb) p chararr $1 = <incomplete type> (gdb) p &chararr $2 = (PTR TO -> ( Type )) 0x7fffffffe5b0 -- Steve