[Bug fortran/64125] New: Allocation of character strings

fmartinez at gmv dot com gcc-bugzilla@gcc.gnu.org
Sun Nov 30 17:50:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64125

            Bug ID: 64125
           Summary: Allocation of character strings
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fmartinez at gmv dot com

Hi.
The following code inside a module causes the compiler to crash (also in the
latest version of 4.9)

   allocate( character(len=size(right))::left%chars )
 ^
internal compiler error: in gimplify_expr, at gimplify.c:8646
0x572c28 ???
    ../sysdeps/x86_64/elf/start.S:113

Cheers,
Fran


type t_string
  private
  character(len=:), allocatable :: chars
end type t_string



pure subroutine string_assign_from_array( left, right )

! The target string
  type(t_string), intent(out) :: left

! The source string
  character, dimension(:), intent(in) :: right


! Copy memory
  allocate( character(len=size(right)) :: left%chars )
  left%chars = transfer( right, left%chars )

end subroutine string_assign_from_array



More information about the Gcc-bugs mailing list