Hi, the attached code leads to an internal error: abstract_conjugate_gradients.f90: In function ‘cg’: abstract_conjugate_gradients.f90:6:0: internal compiler error: in fold_convert_loc, at fold-const.c:2789 Cheers, -ha
Created attachment 18871 [details] Modules and compilation script
Reduced test case: module abstract_gradient implicit none public :: vector_class public :: inner_product_class public :: gradient_class private type, abstract :: vector_class end type vector_class type, abstract :: inner_product_class end type inner_product_class type, abstract, extends(vector_class) :: gradient_class class(inner_product_class), pointer :: my_inner_product => null() contains procedure, public, non_overridable :: inquire_inner_product end type gradient_class contains function inquire_inner_product (this) class(gradient_class) :: this class(inner_product_class), pointer :: inquire_inner_product inquire_inner_product => this%my_inner_product end function inquire_inner_product end module abstract_gradient module abstract_conjugate_gradients use abstract_gradient implicit none contains subroutine cg (g_initial) class(gradient_class), intent(in) :: g_initial class(inner_product_class), pointer :: ip_save ip_save => g_initial%inquire_inner_product() ! ICE end subroutine cg end module abstract_conjugate_gradients The ICE goes away if I comment line 6: private
Backtrace: Breakpoint 1, fold_convert_loc (loc=0, type=0x7fd3e16529a0, arg=0x7fd3e1659000) at /home/jweil/gcc45/trunk/gcc/fold-const.c:2789 2789 gcc_unreachable (); (gdb) bt #0 fold_convert_loc (loc=0, type=0x7fd3e16529a0, arg=0x7fd3e1659000) at /home/jweil/gcc45/trunk/gcc/fold-const.c:2789 #1 0x0000000000590072 in gfc_trans_scalar_assign (lse=0x7fffe96ea410, rse=0x7fffe96ea3c0, ts= {type = BT_CLASS, kind = 0, u = {derived = 0x2310fb0, cl = 0x2310fb0}, interface = 0x0, is_c_interop = 0, is_iso_c = 0, f90_type = BT_UNKNOWN}, l_is_temp=0 '\0', r_is_var=0 '\0') at /home/jweil/gcc45/trunk/gcc/fortran/trans-expr.c:4675 #2 0x00000000005914f6 in gfc_trans_assignment_1 (expr1=0x23178b0, expr2=0x2317b20, init_flag=0 '\0') at /home/jweil/gcc45/trunk/gcc/fortran/trans-expr.c:5119 #3 0x0000000000591916 in gfc_trans_assignment (expr1=0x23178b0, expr2=0x2317b20, init_flag=0 '\0') at /home/jweil/gcc45/trunk/gcc/fortran/trans-expr.c:5260 #4 0x000000000059196e in gfc_trans_assign (code=0x2317bf0) at /home/jweil/gcc45/trunk/gcc/fortran/trans-expr.c:5272 #5 0x0000000000591bf3 in gfc_trans_class_assign (code=0x2317bf0) at /home/jweil/gcc45/trunk/gcc/fortran/trans-expr.c:5336 #6 0x000000000055aac6 in gfc_trans_code (code=0x2317bf0) at /home/jweil/gcc45/trunk/gcc/fortran/trans.c:1094
Further reduced test case: module abstract_gradient implicit none private type, public, abstract :: gradient_class contains procedure, nopass :: inner_product end type contains function inner_product () class(gradient_class), pointer :: inner_product inner_product => NULL() end function end module use abstract_gradient class(gradient_class), pointer :: g_initial, ip_save ip_save => g_initial%inner_product() ! ICE end
This patch fixes it: Index: gcc/fortran/trans-expr.c =================================================================== --- gcc/fortran/trans-expr.c (Revision 153493) +++ gcc/fortran/trans-expr.c (Arbeitskopie) @@ -4660,7 +4660,7 @@ gfc_trans_scalar_assign (gfc_se * lse, gfc_se * rs gfc_add_expr_to_block (&block, tmp); } } - else if (ts.type == BT_DERIVED) + else if (ts.type == BT_DERIVED || ts.type == BT_CLASS) { gfc_add_block_to_block (&block, &lse->pre); gfc_add_block_to_block (&block, &rse->pre); Though I don't quite understand yet, why 'private' makes a difference here.
Subject: Bug 41800 Author: janus Date: Fri Oct 23 16:10:08 2009 New Revision: 153504 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153504 Log: 2009-10-23 Janus Weil <janus@gcc.gnu.org> PR fortran/41800 * trans-expr.c (gfc_trans_scalar_assign): Handle CLASS variables. 2009-10-23 Janus Weil <janus@gcc.gnu.org> PR fortran/41800 * gfortran.dg/class_10.f03: New test. Added: trunk/gcc/testsuite/gfortran.dg/class_10.f03 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-expr.c trunk/gcc/testsuite/ChangeLog
Fixed with r153504. Thanks for the report.