ptype on deferred-length character arrays return empty(?) result
Kazuyoshi Furutaka
furutaka@jb3.so-net.ne.jp
Tue Oct 29 07:47:24 GMT 2024
I've filed a report, and immediately it was marked as a duplicate
of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101826
Kazuyoshi
From: Steve Kargl <sgk@troutmask.apl.washington.edu>
Subject: Re: ptype on deferred-length character arrays return empty(?) result
Date: Mon, 28 Oct 2024 11:46:13 -0700
> 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
More information about the Fortran
mailing list