Bug 47224 - [F03] ICE with procedure pointer component
[F03] ICE with procedure pointer component
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: fortran
4.6.0
: P3 normal
: ---
Assigned To: janus
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-01-08 17:07 UTC by Martien Hulsen
Modified: 2011-01-10 08:51 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-01-09 09:46:33


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martien Hulsen 2011-01-08 17:07:56 UTC
The code below gives:

t.f90: In function ‘poisson_natboun_surface’:
t.f90:23:0: internal compiler error: in gfc_walk_variable_expr, at fortran/trans-array.c:7325
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Note, that if xg(:) is replaced with xg it compiles normally.

module element_defs_m
  use kind_defs_m
  type coefficients_t
    procedure (dum_vfunc), pointer, nopass :: vfunc => null()
  end type coefficients_t
contains
  function dum_vfunc ( n, x )
    integer, intent(in) :: n
    real, intent(in), dimension(:) :: x
    real, dimension(n) :: dum_vfunc
    dum_vfunc = 0
  end function dum_vfunc
end module element_defs_m
module poisson_elements_m
  use element_defs_m
  implicit none
contains
  subroutine poisson_natboun_surface ( coefficients )
    type(coefficients_t), intent(in) :: coefficients
    real, allocatable, dimension(:) :: xg, normal
    real :: a
    integer :: ndim = 3
    a = dot_product ( normal, coefficients%vfunc ( ndim, xg(:) ) )
  end subroutine poisson_natboun_surface
end module poisson_elements_m
Comment 1 Martien Hulsen 2011-01-09 07:35:28 UTC
The second line should be removed. Modified code:

module element_defs_m
  type coefficients_t
    procedure (dum_vfunc), pointer, nopass :: vfunc => null()
  end type coefficients_t
contains
  function dum_vfunc ( n, x )
    integer, intent(in) :: n
    real, intent(in), dimension(:) :: x
    real, dimension(n) :: dum_vfunc
    dum_vfunc = 0
  end function dum_vfunc
end module element_defs_m
module poisson_elements_m
  use element_defs_m
  implicit none
contains
  subroutine poisson_natboun_surface ( coefficients )
    type(coefficients_t), intent(in) :: coefficients
    real, allocatable, dimension(:) :: xg, normal
    real :: a
    integer :: ndim = 3
    a = dot_product ( normal, coefficients%vfunc ( ndim, xg(:) ) )
  end subroutine poisson_natboun_surface
end module poisson_elements_m
Comment 2 janus 2011-01-09 09:46:33 UTC
Confirmed. Thanks for reporting. Here is a slightly reduced/modified test case:

  abstract interface
    real function dum_vfunc ( x )
      real, dimension(:) :: x
    end function
  end interface

  type coefficients_t
    procedure (dum_vfunc), pointer, nopass :: vfunc
  end type

  type(coefficients_t) :: coeff
  real, dimension(3) :: x
  print *, abs ( coeff%vfunc ( x(:) ) )

end
Comment 3 janus 2011-01-09 17:45:24 UTC
Mine. The following patch fixes the test case and does not produce any regressions on the "proc_*" test cases, which means it's probably fine:


Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 168609)
+++ gcc/fortran/resolve.c	(working copy)
@@ -1528,7 +1528,6 @@ resolve_actual_arglist (gfc_actual_arglist *arg, p
   gfc_symtree *parent_st;
   gfc_expr *e;
   int save_need_full_assumed_size;
-  gfc_component *comp;
 
   for (; arg; arg = arg->next)
     {
@@ -1548,20 +1547,6 @@ resolve_actual_arglist (gfc_actual_arglist *arg, p
 	  continue;
 	}
 
-      if (gfc_is_proc_ptr_comp (e, &comp))
-	{
-	  e->ts = comp->ts;
-	  if (e->expr_type == EXPR_PPC)
-	    {
-	      if (comp->as != NULL)
-		e->rank = comp->as->rank;
-	      e->expr_type = EXPR_FUNCTION;
-	    }
-	  if (gfc_resolve_expr (e) == FAILURE)                          
-	    return FAILURE; 
-	  goto argument_list;
-	}
-
       if (e->expr_type == EXPR_VARIABLE
 	    && e->symtree->n.sym->attr.generic
 	    && no_formal_args


Will commit as obvious after a full regtest.
Comment 4 Martien Hulsen 2011-01-09 19:04:27 UTC
(In reply to comment #3)
Yes, this fixes the ICE. My full code also compiles now. Thanks.
I now have a segfault when running the code. Will send a bug report after I manage to reduce the code.
Comment 5 janus 2011-01-09 21:01:41 UTC
Author: janus
Date: Sun Jan  9 21:01:38 2011
New Revision: 168618

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168618
Log:
2011-01-09  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/47224
	* resolve.c (resolve_actual_arglist): Remove unneeded and buggy piece
	of code.


2011-01-09  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/47224
	* gfortran.dg/proc_ptr_comp_28.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_comp_28.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 janus 2011-01-09 21:17:08 UTC
(In reply to comment #4)
> Yes, this fixes the ICE. My full code also compiles now.

The patch has been committed as r168618. So we can close this PR.


> I now have a segfault when running the code. Will send a bug report after I
> manage to reduce the code.

A segfault is not necessarily a compiler bug, but in case it is, a reduced test case would be very helpful.
Comment 7 Martien Hulsen 2011-01-10 08:51:19 UTC
(In reply to comment #6)
> (In reply to comment #4)

> > I now have a segfault when running the code. Will send a bug report after I
> > manage to reduce the code.
> 
> A segfault is not necessarily a compiler bug, but in case it is, a reduced test
> case would be very helpful.

Bug report posted as http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47240