Bug 46841 - [F03] ICE on allocating array of procedure pointers
[F03] ICE on allocating array of procedure pointers
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: fortran
4.6.0
: P3 normal
: ---
Assigned To: janus
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-12-07 18:27 UTC by Martien Hulsen
Modified: 2010-12-13 16:19 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-12-07 19:44:18


Attachments
source file of module (627 bytes, text/plain)
2010-12-07 18:28 UTC, Martien Hulsen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martien Hulsen 2010-12-07 18:27:37 UTC
The attached file gives:

gfortran -c  -O2    element_defs.f90
element_defs.f90: In function ‘create_coefficients’:
element_defs.f90:20:0: internal compiler error: in
gfc_conv_descriptor_data_get, at fortran/trans-array.c:144
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Martien Hulsen 2010-12-07 18:28:26 UTC
Created attachment 22676 [details]
source file of module
Comment 2 Dominique d'Humieres 2010-12-07 18:46:31 UTC
Confirmed on trunk and 4.5.0. If I replace

    procedure (dum_vfunc), pointer, nopass :: p => null()

with


    procedure (dum_vfunc), pointer, nopass :: p

the ICE goes away.
Comment 3 janus 2010-12-07 19:44:18 UTC
Confirmed. Slightly reduced test case:



  type vfunc_p
    procedure (dum_vfunc), pointer, nopass :: p => null()
  end type vfunc_p

  type(vfunc_p), allocatable, dimension(:) :: vfunc1 

  allocate(vfunc1(10))

contains

  function dum_vfunc ()
    real, dimension(2) :: dum_vfunc
    dum_vfunc = 0
  end function dum_vfunc

end
Comment 4 janus 2010-12-13 14:30:41 UTC
Here's the fix:


Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c    (revision 167730)
+++ gcc/fortran/trans-expr.c    (working copy)
@@ -4452,7 +4452,7 @@
                                        gfc_class_null_initializer (&cm->ts));
       gfc_add_expr_to_block (&block, tmp);
     }
-  else if (cm->attr.dimension)
+  else if (cm->attr.dimension && !cm->attr.proc_pointer)
     {
       if (cm->attr.allocatable && expr->expr_type == EXPR_NULL)
        gfc_conv_descriptor_data_set (&block, dest, null_pointer_node);


Will commit as obvious after regtesting.
Comment 5 janus 2010-12-13 16:16:10 UTC
Author: janus
Date: Mon Dec 13 16:16:06 2010
New Revision: 167750

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167750
Log:
2010-12-13  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/46841
	* trans-expr.c (gfc_trans_subcomponent_assign): Handle array-valued
	procedure pointer components.

2010-12-13  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/46841
	* gfortran.dg/proc_ptr_comp_26.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_comp_26.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 janus 2010-12-13 16:19:31 UTC
Fixed with r167750. Closing.