http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52143
Bug #: 52143 Summary: [OOP] ICE with polymorphic function result in gfc_class_vptr_get Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org CC: pa...@gcc.gnu.org Found when creating a test case for PR 51514. The following code causes an test.f90:8:0: internal compiler error: tree check: expected record_type or union_type or qual_union_type, have function_type in gfc_class_vptr_get, at fortran/trans-expr.c:78 which is at vptr = gfc_advance_chain (TYPE_FIELDS (TREE_TYPE (decl)), CLASS_VPTR_FIELD); Backtrace: #0 gfc_class_vptr_get (decl=0x2aaaacce2600) at trans-expr.c:78 #1 0x00000000005d3f0d in gfc_vtable_field_get (decl=<optimized out>, field=1) at trans-expr.c:91 #2 0x00000000005b1fa5 in build_class_array_ref (index=0x2aaaacbc3c90, base=0x2aaaacced2a8, se=<optimized out>) at trans-array.c:2984 #3 gfc_conv_scalarized_array_ref (se=0x7fffffffce20, ar=<optimized out>) at trans-array.c:3037 #4 0x00000000005b2852 in gfc_conv_array_ref (se=0x7fffffffce20, ar=0x174a888, sym=<optimized out>, where=<optimized out>) at trans-array.c:3112 #5 0x00000000005db098 in gfc_conv_variable (se=0x7fffffffce20, expr=0x174a620) at trans-expr.c:1333 #6 0x00000000005da874 in gfc_conv_expr_reference (se=0x7fffffffce20, expr=<optimized out>) at trans-expr.c:5610 #7 0x00000000005de0b0 in gfc_conv_procedure_call (se=0x7fffffffcff0, sym=0x173e1f0, args=0x1746b50, expr=0x174aa10, append_args=0x0) at trans-expr.c:3540 #8 0x00000000006020c5 in gfc_trans_call (code=0x174af90, dependency_check=<optimized out>, mask=0x0, count1=0x0, invert=false) at trans-stmt.c:468 module mod_subpr type :: foo integer :: i = 2 end type contains function g () class(foo), allocatable :: g(:) allocate (g(3)) end function g end module