http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60477
Bug ID: 60477
Summary: unlimited type class(*) not working properly
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: ghasemi.arash at gmail dot com
Created attachment 32320
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32320&action=edit
source file
hey folks. I couldn't use an unlimited pointer "class(*), pointer" inside a
procedure. here I've got a simple module that has a base data type named "ex1"
and a child type "ex2" that extends "ex1".
================================================================
module oop2
implicit none
private
type ex1
integer :: a
end type ex1
type, extends(ex1) :: ex2
real*8 :: b
end type ex2
public :: ex1, ex2, printit
contains
subroutine printit(ex)
implicit none
class(ex1), target, intent(in) :: ex
! local vars
class(*), pointer :: pnt => null()
pnt => ex ! buggy :(
end subroutine printit
end module oop2
================================================================
The problem arises inside "printit" procedure. When I defined the unlimited
pointer "class(*), pointer :: pnt" it cause no problem and code compiles fine
with gfortran 4.8.1. However when I start pointing to the subroutine's dummy
argument "ex" I get the following error:
================================================================
new_bug.f90:31:0: internal compiler error: Segmentation fault
end module oop2
^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.opensuse.org/> for instructions.
================================================================
This code compiles fine with ifort. Here is the main program that I used
================================================================
program test
use oop2
implicit none
type(ex1) :: b
b%a = 2
call printit(b)
! done here
end program test
================================================================
The intel compiler also works fine with polymorphic data when I use different
type for variable "b" defined in the main program like "type(ex2) :: b". Thanks