This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/37626] ICE for automatic deallocation of character result variable
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Sep 2008 19:43:30 -0000
- Subject: [Bug fortran/37626] ICE for automatic deallocation of character result variable
- References: <bug-37626-16749@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from burnus at gcc dot gnu dot org 2008-09-23 19:43 -------
It fails for the following assert:
gfc_conv_descriptor_data_get (tree desc)
{
tree field, type, t;
type = TREE_TYPE (desc);
gcc_assert (GFC_DESCRIPTOR_TYPE_P (type));
Reduced test case:
function unique_A (x) result (x_unique)
implicit none
character(*), dimension(:), intent(in) :: x
character(LEN(x)), dimension(:), allocatable :: x_unique
character(LEN(x)), dimension(5) :: x_sorted
logical, dimension(4) :: mask
mask = (/ x_sorted(2:5) /= x_sorted(1:4) /)
allocate(x_unique(COUNT(mask)))
end function unique_A
If one one changes the program to "function x_unique(x)", i.e. sym ==
sym->result, it works. The same is true if the character length is explicitly
set for x_unique (or for x, which implies the latter).
Debugging shows the following call tree for "x_unique":
#0 gfc_conv_descriptor_data_get
#1 gfc_trans_dealloc_allocated
#2 gfc_trans_deferred_array
Thus the ICE happens for the automatic deallocation of "x_unique". But as
x_unique is a result variable that should not happen!
Patch:
--- trans-array.c (Revision 140615)
+++ trans-array.c (Arbeitskopie)
@@ -5754,7 +5754,7 @@ gfc_trans_deferred_array (gfc_symbol * s
gfc_add_expr_to_block (&fnblock, tmp);
}
- if (sym->attr.allocatable && !sym->attr.save)
+ if (sym->attr.allocatable && !sym->attr.save && !sym->attr.result)
{
tmp = gfc_trans_dealloc_allocated (sym->backend_decl);
gfc_add_expr_to_block (&fnblock, tmp);
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu dot
| |org
OtherBugsDependingO| |32834
nThis| |
AssignedTo|unassigned at gcc dot gnu |burnus at gcc dot gnu dot
|dot org |org
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
GCC build triplet|x86_64-gentoo-linux |
GCC host triplet|x86_64-gentoo-linux |
GCC target triplet|x86_64-gentoo-linux |
Keywords| |ice-on-valid-code
Last reconfirmed|0000-00-00 00:00:00 |2008-09-23 19:43:30
date| |
Summary|Internal compiler error |ICE for automatic
|triggered by gfortran PACK |deallocation of character
|intrinsic |result variable
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37626