Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Child type initialization ICE

jahern
Beginner
605 Views
Hello,

I receive an internal compiler error when compiling the following code:
[fortran]MODULE Error
   IMPLICIT NONE
   TYPE, ABSTRACT :: Parent
   END TYPE Parent
   TYPE, EXTENDS(Parent) :: Child
   ! TYPE Child ! workaround 1
      INTEGER :: i = 1
   END TYPE Child
   TYPE(Child), PARAMETER :: OBJ = Child()
   ! TYPE(Child), PARAMETER :: OBJ = Child(1) ! workaround 2
END MODULE Error[/fortran]
The resulting error is:
[plain]/tmp/ifortPvVk9s.i90: catastrophic error: **Internal compiler error: segmentation violation signal raised**
Please report this error along with the circumstances in which it occurred in a Software Problem Report.
Note: File and line given may not be explicit cause of this error.
compilation aborted for error.F90 (code 1)[/plain]
Note that the use of either of the workarounds removes the error. I believe it is related to ifort's checking that all of the components within the type are initialized.This error occurred on Fedora 14 x64 with ifort12.0.0 20101116 froml_fcompxe_intel64_2011.1.107.

Regards,
Jared Ahern
0 Kudos
3 Replies
Dharma
Beginner
605 Views
The code works fine with gfortran (4.5.1)

Have look at the following code
[fortran]   MODULE Error
      IMPLICIT NONE
      TYPE,abstract :: Parent
      END TYPE Parent
      TYPE, EXTENDS(Parent)  :: Child
      ! TYPE Child ! workaround 1

         real :: r
         INTEGER :: i = 1
      END TYPE Child
      !type(child),parameter :: OBJ = Child(r=5.0) ! Compiles with gfortran but not with ifort
      !type(child),parameter :: OBJ = Child(r=5.0,i=2) ! Compiles with gfortran does not Compile with ifort
       type(child),parameter :: obj = child(5.0,2) ! does not compile with gfortran, compiles with ifort but prints a wrong answer
      ! type(child),parameter :: obj = child(5.0) ! does not compile with ifort and gfortran
      !------------------------
       ! Looks like iforts implimentation is inconsitant with the following rules
       ! and gfortran doesnot seem to intialize unless keyword is used
       ! ofcourse the problems seem to be specific to type extension (even if the parent is not abstract)
 !C483(R457) At most one component-spec shall be provided for a component.
 !C484(R457) If a component-spec is provided for a component,no component-spec shall be provided
 !           for any component with which it is inheritance associated.
 !C485(R457) A component-spec shall be provided for a component unless it has default initialization
 !           or is inheritance associated with another component for which a component-spec is provided or
 !           that has default initialization
 !C486(R458) The keyword=may be omitted from a component-spec only ifthe keyword= has been
 !            omitted from each preceding component-spec in the constructor.

      !-------------------------
      ! TYPE(Child), PARAMETER :: OBJ = Child(1) ! workaround 2
  END MODULE Error
  program Test
   use Error
   print*,obj%i,obj%r
  end program Test
[/fortran]

Is C483 inconsitent with C485 when the derived type has only on component and it is default initialized.
0 Kudos
Xiaoping_D_Intel
Employee
605 Views
I will submit a bug report on the internal compiler error.

Thanks,
Xiaoping Duan
Intel Customer support
0 Kudos
jahern
Beginner
604 Views
Thanks! Another note - I found that workaround 2 needs explicit type constructors if any derived types are included in the child type (e.g. "TYPE(Child),PARAMETER::OBJ=Child(1,SomeType(4.5))"). That syntax is not really a surprise though.
0 Kudos
Reply