The code below compiles well with ifort (IFORT) 15.0.0 20140723 under Linux, however, it terminates abruptly when accessing an array element. There is no error message or stack traceback even when using
ifort -o testing -stand f08 -check bounds -nologo -fpe:0 -debug full -O0 -warn all -traceback -dbglibs testing.f90
to compile.
----8<--------8<--------8<--------8<--------8<--------8<--------8<----
MODULE class_IFoo
IMPLICIT NONE
PRIVATE
TYPE, ABSTRACT, PUBLIC :: IFoo
CONTAINS
PROCEDURE(getBarI), DEFERRED, PUBLIC :: getBar
PROCEDURE(setBarI), DEFERRED, PUBLIC :: setBar
END TYPE IFoo
ABSTRACT INTERFACE
INTEGER FUNCTION getBarI( this ) RESULT( bar )
IMPORT :: IFoo
CLASS(IFoo), INTENT(in) :: this
END FUNCTION getBarI
SUBROUTINE setBarI( this, bar )
IMPORT :: IFoo
CLASS(IFoo), INTENT(inout) :: this
INTEGER, INTENT(in) :: bar
END SUBROUTINE setBarI
END INTERFACE
END MODULE class_IFoo
MODULE class_TFoo
USE class_IFoo, ONLY : IFoo
IMPLICIT NONE
PRIVATE
TYPE, EXTENDS(IFoo), PUBLIC :: TFoo
INTEGER :: bar
CONTAINS
PROCEDURE, PUBLIC :: getBar
PROCEDURE, PUBLIC :: setBar
END TYPE TFoo
CONTAINS
INTEGER FUNCTION getBar( this ) RESULT(bar)
CLASS(TFoo), INTENT(in) :: this
bar = this % bar
END FUNCTION getBar
SUBROUTINE SetBar( this, bar)
CLASS(TFoo), INTENT(inout) :: this
INTEGER, INTENT(in) :: bar
this % bar = bar
END SUBROUTINE SetBar
END MODULE class_TFoo
PROGRAM test_array_of_abstract
USE class_IFoo, ONLY : IFoo
USE class_TFoo, ONLY : TFoo
IMPLICIT NONE
INTEGER, PARAMETER :: N = 2
INTEGER :: i, bar
CLASS(IFoo), ALLOCATABLE :: foo(:)
CLASS(IFoo), ALLOCATABLE :: fooSource
ALLOCATE( TFoo :: fooSource )
CALL fooSource % setBar( 13 )
PRINT '(A,I2)', 'The bar value of the source is set to ', fooSource % getBar()
ALLOCATE( foo, SOURCE = SPREAD( fooSource, 1, N ) )
DO i = 1, N
PRINT '(A,I2)', 'Getting bar from foo#', i
bar = foo(i)%getBar() ! This line terminates the code with no message
PRINT '(A,I2)', 'Found bar to be', bar
END DO
END PROGRAM test_array_of_abstract