Here is some example code:
program test_function_constructor implicit none abstract interface integer function get_int() end function get_int end interface type :: foo procedure(get_int), nopass, pointer :: get => null() end type foo type(foo) :: bar bar = foo(foo_int) ! Causes ICE bar%get => foo_int ! OK (my current workaround) contains integer function foo_int() foo_int = 0 end function foo_int end program test_function_constructor
There was a previous bug about a similar issue here:
http://software.intel.com/en-us/forums/topic/270982
That bug was fixed and the test case there still is OK. This new bug triggers in different circumstances. Namely:
- The type being constructed must be declared in the same module (or as above, program block) as the code that uses the constructor.
- The procedure pointer must point to a function, not a subroutine.
If either of those conditions isn't met, the code compiles fine. Unlike the earlier issue, it doesn't matter in this case if you default-initialize the function pointer to null().