http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54070

             Bug #: 54070
           Summary: Wrong code with allocatable deferred-length (array)
                    function results
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: bur...@gcc.gnu.org
                CC: dam...@rouson.net, pa...@gcc.gnu.org


As reported by Damian at http://gcc.gnu.org/ml/fortran/2012-07/msg00117.html ,
allocatable deferred-length (array) function results have issues.


The following code gives a segfault - or with tree checking:
gfc_add_modify_loc, at fortran/trans.c:160

function f()
  character(len=:),allocatable :: f
  f ="ABC"
end function


The following (invalid) program gives an ICE:
  in gimplify_var_or_parm_decl, at gimplify.c:2048
(the program is invalid as one assigns a scalar to an unallocated array)

function f(a)
  character(len=*) :: a
  character(len=:),allocatable :: f(:)
  f = a
end function



One gets the same ICE for the original example. Looking at the dump, there is
no (re)allocation - but there should be one!

module deferred_length_char_array
contains
  function return_string(argument)
    character(*) :: argument
    character(:), dimension(:), allocatable :: return_string
    return_string = argument
  end function 
end module

Reply via email to