[Bug fortran/37626] ICE for automatic deallocation of character result variable

2008-09-23 Thread burnus 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|-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



[Bug fortran/37626] ICE for automatic deallocation of character result variable

2008-09-24 Thread burnus at gcc dot gnu dot org


--- Comment #3 from burnus at gcc dot gnu dot org  2008-09-24 07:02 ---
Subject: Bug 37626

Author: burnus
Date: Wed Sep 24 07:01:18 2008
New Revision: 140624

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140624
Log:
2008-09-24  Tobias Burnus  <[EMAIL PROTECTED]>

PR fortran/37626
* trans-array.c (gfc_trans_deferred_array): Don't auto-deallocate
result variables.

2008-09-24  Tobias Burnus  <[EMAIL PROTECTED]>

PR fortran/37626
* gfortran.dg/allocatable_function_4.f90: New test.


Added:
trunk/gcc/testsuite/gfortran.dg/allocatable_function_4.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-array.c
trunk/gcc/testsuite/ChangeLog


-- 


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



[Bug fortran/37626] ICE for automatic deallocation of character result variable

2008-09-25 Thread burnus at gcc dot gnu dot org


--- Comment #4 from burnus at gcc dot gnu dot org  2008-09-25 16:20 ---
Subject: Bug 37626

Author: burnus
Date: Thu Sep 25 16:18:45 2008
New Revision: 140667

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140667
Log:
2008-09-25  Tobias Burnus  <[EMAIL PROTECTED]>

PR fortran/37626
* trans-array.c (gfc_trans_deferred_array): Don't
* auto-deallocate
result variable.

2008-09-25  Tobias Burnus  <[EMAIL PROTECTED]>

PR fortran/37626
* gfortran.dg/allocatable_function_4.f90: New test.


Added:
   
branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/allocatable_function_4.f90
Modified:
branches/gcc-4_3-branch/gcc/fortran/ChangeLog
branches/gcc-4_3-branch/gcc/fortran/trans-array.c
branches/gcc-4_3-branch/gcc/testsuite/ChangeLog


-- 


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



[Bug fortran/37626] ICE for automatic deallocation of character result variable

2008-09-25 Thread burnus at gcc dot gnu dot org


--- Comment #5 from burnus at gcc dot gnu dot org  2008-09-25 16:21 ---
FIXED on the trunk (4.4.0) and on the 4.3 branch.

Thanks for the bug report!


-- 

burnus at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED


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