Bug 46413 - [OOP] ICE when printing a polymorphic type
Summary: [OOP] ICE when printing a polymorphic type
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2010-11-10 13:53 UTC by Tobias Burnus
Modified: 2010-11-11 23:08 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2010-11-10 13:53:24 UTC
The following invalid program gives an ICE:
test.f90:7:0: internal compiler error: Bad IO basetype (7)


type t
  integer :: ii =5
end type t
class(t), allocatable :: x
allocate (t :: x)

print *,x  ! PRINT of polymorphic type.
end


ifort prints:
test.f90(7): error #8303: A list item shall not be polymorphic unless it is processed by a user-defined derived-type input/output procedure.   [X]

"9.6.3 Data transfer input/output list"
"A list item shall not be polymorphic unless it is processed by a dened input/output procedure (9.6.4.8)."
Comment 1 Tobias Burnus 2010-11-11 09:16:08 UTC
Untested patch:

Index: resolve.c
===================================================================
--- resolve.c   (Revision 166596)
+++ resolve.c   (Arbeitskopie)
@@ -7948,6 +7948,15 @@ resolve_transfer (gfc_code *code)
     if (ref->type == REF_COMPONENT)
       ts = &ref->u.c.component->ts;

+  if (ts->type == BT_CLASS)
+    {
+      /* FIXME: Test whether there defined input/output is done.  */
+      gfc_error ("Data transfer element at %L cannot be polymorphic unless "
+                "it is processed by a defined input/output procedure",
+                &code->loc);
+      return;
+    }
+
   if (ts->type == BT_DERIVED)
     {
       /* Check that transferred derived type doesn't contain POINTER
Comment 2 Tobias Burnus 2010-11-11 23:07:27 UTC
Author: burnus
Date: Thu Nov 11 23:07:23 2010
New Revision: 166631

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=166631
Log:
2010-11-11  Tobias Burnus  <burnus@net-b.de>

        PR fortran/46413
        * resolve.c (resolve_transfer): Reject I/O transfer of
        polymorphic type.

        PR fortran/46205
        * resolve.c (resolve_code): Reject nonscalar FORALL masks.

2010-11-11  Tobias Burnus  <burnus@net-b.de>

        PR fortran/46413
        * gfortran.dg/class_31.f90: New.

        PR fortran/46205
        * gfortran.dg/forall_14.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/class_31.f90
    trunk/gcc/testsuite/gfortran.dg/forall_14.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Tobias Burnus 2010-11-11 23:08:37 UTC
FIXED on the trunk (4.6).