I've had some issues trying to make some Fortran tests work (they use pFUnit, which requires most of Fortran 2003 to be implemented). It's rather difficult to reduce the test cases, partly because I get a lot of different symptoms (e.g. segfaults, hanging), and partly because there is generated code in the unit test framework, which is hard to modify by hand without causing problems.
Anyway, I've been trying to figure out whether there are bugs in ifort 14.0 that are contributing to this. I mocked up a case that has some similarities to the code I'm trying to debug, and managed to find an error in the handling of an allocatable.
module foo_bar_types implicit none type :: array_type integer, allocatable :: array(:) end type array_type abstract interface type(array_type) function get_array_wrapper() import :: array_type end function get_array_wrapper end interface type :: foo procedure(get_array_wrapper), pointer, nopass :: getter => null() end type foo end module foo_bar_types program test_polymorphic_allocation use foo_bar_types implicit none type(foo) :: bar_source class(foo), allocatable :: bar_poly integer :: i allocate(bar_poly, source=bar_source) deallocate(bar_poly) end program test_polymorphic_allocation
I guess the first question that comes to mind is, have I done something wrong, or does this look like a potential bug in ifort? This test case is maximally reduced and bizarrely specific. The error goes away if:
- foo is defined in the program instead of a separate module.
- bar_poly is changed to not be polymorphic.
- foo does not contain the specific component it does, namely:
- A pointer to a procedure,
- that returns a derived type,
- with an allocatable, array component.
If you remove the "deallocate" statement from the test case, then the error goes away, but valgrind still finds an issue with the allocate statement.