This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/54070] New: Wrong code with allocatable deferred-length (array) function results
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 23 Jul 2012 09:32:52 +0000
- Subject: [Bug fortran/54070] New: Wrong code with allocatable deferred-length (array) function results
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
CC: damian@rouson.net, pault@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