Bug 44565 - [4.6 Regression] [OOP] ICE in gimplify_expr with array-valued generic TBP
Summary: [4.6 Regression] [OOP] ICE in gimplify_expr with array-valued generic TBP
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: janus
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2010-06-17 10:26 UTC by Hans-Werner Boschmann
Modified: 2010-07-13 08:56 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-07-11 09:41:26


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hans-Werner Boschmann 2010-06-17 10:26:12 UTC
module ice6

  type :: lin_approx_cont_type
     real,dimension(:),allocatable::values
   contains
     procedure::get_array
     procedure::get_element
     generic::get_something=>get_element,get_array
  end type lin_approx_cont_type

  contains

  pure function get_element(this,index)
    class(lin_approx_cont_type),intent(in)::this
    integer,intent(in)::index
    real::get_element
    get_element=this%values(index)
  end function get_element

  pure function get_array(this)
    class(lin_approx_cont_type),intent(in)::this
    real,dimension(this%dim)::get_array
    get_array=this%values
  end function get_array
  
  subroutine do_something(this)
    class(lin_approx_cont_type),intent(in)::this
    call really_do_something(this%get_something())
  end subroutine do_something

  subroutine really_do_something(array)
    real,dimension(:),intent(in)::array
  end subroutine really_do_something

end module ice6


compiling with GNU Fortran (GCC) 4.6.0 20100616 results in:
ice6.f03:35:0: interner Compiler-Fehler: in gimplify_expr, bei gimplify.c:7389
Comment 1 Dominique d'Humieres 2010-06-17 11:07:35 UTC
Confirmed on thrunk after having added

     integer :: dim = 2

in 'type :: lin_approx_cont_type'. The modified code compile with  4.5.0, hence a regression I can trace between revisions 158215 (working) and 158921 (ICE).
Comment 2 janus 2010-06-17 22:34:38 UTC
Reduced test case:


module ice6

  type :: t
   contains
     procedure :: get_array
     generic :: get_something => get_array
  end type

contains

  function get_array(this)
    class(t) :: this
    real,dimension(2) :: get_array
  end function get_array

  subroutine do_something(this)
    class(t) :: this
    print *,this%get_something()
  end subroutine do_something

end module ice6 


The problem is not related to passing the TBP as an argument, but the TBP has to be generic and array-valued.
Comment 3 janus 2010-06-17 22:59:12 UTC
(In reply to comment #1)
> The modified code compile with  4.5.0, hence
> a regression I can trace between revisions 158215 (working) and 158921 (ICE).


The regression is most probably due to the merging of the fortran-dev branch:

r158910 | pault | 2010-04-29 21:10:48 +0200 (Thu, 29 Apr 2010) | 164 lines
Comment 4 janus 2010-07-11 09:41:26 UTC
Mine. Patch coming soon.
Comment 5 janus 2010-07-13 06:57:39 UTC
Subject: Bug 44565

Author: janus
Date: Tue Jul 13 06:57:17 2010
New Revision: 162125

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

	PR fortran/44434
	PR fortran/44565
	PR fortran/43945
	PR fortran/44869
	* gfortran.h (gfc_find_derived_vtab): Modified prototype.
	* class.c (gfc_build_class_symbol): Modified call to
	'gfc_find_derived_vtab'.
	(add_proc_component): Removed, moved code into 'add_proc_comp'.
	(add_proc_comps): Renamed to 'add_proc_comp', removed treatment of
	generics.
	(add_procs_to_declared_vtab1): Removed unnecessary argument 'resolved'.
	Removed treatment of generics.
	(copy_vtab_proc_comps): Removed unnecessary argument 'resolved'.
	Call 'add_proc_comp' instead of duplicating code.
	(add_procs_to_declared_vtab): Removed unnecessary arguments 'resolved'
	and 'declared'.
	(add_generic_specifics,add_generics_to_declared_vtab): Removed.
	(gfc_find_derived_vtab): Removed unnecessary argument 'resolved'.
	Removed treatment of generics.
	* iresolve.c (gfc_resolve_extends_type_of): Modified call to
	'gfc_find_derived_vtab'.
	* resolve.c (resolve_typebound_function,resolve_typebound_subroutine):
	Removed treatment of generics.
	(resolve_select_type,resolve_fl_derived): Modified call to
	'gfc_find_derived_vtab'.
	* trans-decl.c (gfc_get_symbol_decl): Ditto.
	* trans-expr.c (gfc_conv_derived_to_class,gfc_trans_class_assign):
	Ditto.
	* trans-stmt.c (gfc_trans_allocate): Ditto.

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

	PR fortran/44434
	PR fortran/44565
	PR fortran/43945
	PR fortran/44869
	* gfortran.dg/dynamic_dispatch_1.f03: Fixed invalid test case.
	* gfortran.dg/dynamic_dispatch_2.f03: Ditto.
	* gfortran.dg/dynamic_dispatch_3.f03: Ditto.
	* gfortran.dh/typebound_call_16.f03: New.
	* gfortran.dg/typebound_generic_6.f03: New.
	* gfortran.dg/typebound_generic_7.f03: New.
	* gfortran.dg/typebound_generic_8.f03: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/typebound_call_16.f03
    trunk/gcc/testsuite/gfortran.dg/typebound_generic_6.f03
    trunk/gcc/testsuite/gfortran.dg/typebound_generic_7.f03
    trunk/gcc/testsuite/gfortran.dg/typebound_generic_8.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/class.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/iresolve.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans-stmt.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/dynamic_dispatch_1.f03
    trunk/gcc/testsuite/gfortran.dg/dynamic_dispatch_2.f03
    trunk/gcc/testsuite/gfortran.dg/dynamic_dispatch_3.f03

Comment 6 Tobias Burnus 2010-07-13 08:56:13 UTC
Close as FIXED. Thanks to Hans-Werner for the bug report and to Janus for the patch!