Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
27 Views

Derived type array with allocatable components forgets components allocation status

I'm having problems with the following program

program test_allocatable
  use inheritance_stuff, only : base, extender
  implicit none
  class(base), allocatable :: obj(:)
  integer :: i, n
  n = 6
  allocate(extender :: obj(n))
  do i = 1,n
     allocate(obj(i)%array(1))
     write(*,*) allocated(obj(i)%array)
  end do
end program test_allocatable

with the module

module inheritance_stuff
  implicit none
  type base
     double precision, allocatable :: array(:)
  end type base
  type, extends(base) :: extender
     double precision :: whatever
  end type extender
end module inheritance_stuff

When compiled with ifort 18.0.0 20170811 on CentOS Linux 7.4.1708 the resulting program gives the following output

 T
 F
 F
 F
 F
 T

The derived type seems to 'forget' the allocation status of it's components, and if I were to subsequently use one these components it would lead to a segmentation fault.

0 Kudos
1 Reply
Highlighted
New Contributor III
27 Views

Hi, I can conform that behavior for PSXE 2017 u6, PSXE2018 u3 and PSXE2019beta u1 (on win 10, if it matters). Whether this is a bug I cannot say. I've observed, if you change line 4 in the program part from 'class' to 'type' and allocate 'obj' as 'base' the answer is for all components 'T'.

Old gcc 5.4.0 20160609 compiles and runs the original example without errors and produces for all components 'T'. That means not that gfortran or the code is standard conforming, but it smells like a bug in ifort.

I would file it to OSC (https://supporttickets.intel.com/?lang=en-US).

Johannes

0 Kudos