Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28459 Discussions

Constructor interface with class pointer function return bug

Patrice_l_
Beginner
244 Views

Hi,

I tried to track this one down and isolate the bug but I can't reproduce the same error. The bug comes from a constructor interface which take in input the class pointer directly from a function. This code gives an error #8212: Omitted field is not initialized. Field initialization missing:   , but using the true function name works and using an intermediate pointer also works.  I got this behavior with 15.0.2 and 16.  Another similar setup but with more type redirection gives abstract_list.f90(57): error #6678: When the target is an expression it must deliver a pointer result.       newLink => link(val, this%lastLink%nextLink()). this code is available online.

 

 

 

module tt
implicit none
public :: tata
type tata
        class(*),pointer :: val
        type(tata),pointer :: next
        integer :: i
        contains
                procedure,pass :: returnpt
end type
interface tata
        module procedure constructor
end interface
contains
        function returnpt(this)
                class(tata) :: this
                class(tata),pointer :: returnpt
                returnpt => this%next
        end function
subroutine pp(this,val)
class(tata) :: this        
class(*) :: val
class(tata),pointer :: pt,tk

tk => this%returnpt()
pt=>tata(val,tk)
pt=>constructor(val,tk)
pt=>constructor(val,this%returnpt())
pt=>tata(val,this%returnpt()) ! comment this and it works

end subroutine
function constructor(i,tk)
        class(*) :: i
        class(tata),pointer :: constructor,tk
        allocate(constructor)
end function

end module tt
program toto
        use tt
implicit none

class(*),pointer :: obj
class(tata),pointer :: pt


call pp(pt,obj)
   

end program toto

 

0 Kudos
3 Replies
Martyn_C_Intel
Employee
244 Views

I was able to reproduce this. We'll escalate to the compiler developers, and let you know what they say.

Thanks for the report and clean test case!

0 Kudos
Martyn_C_Intel
Employee
244 Views

A fix has been implemented for this issue and I have confirmed that your test case compiled successfully with a development compiler. The fix should be contained in the 16.0 release, we'll let you know when that's available.

0 Kudos
Martyn_C_Intel
Employee
244 Views

The 16.0 compiler has now been released as part of Intel Parallel Studio XE 2016. It is available for download from https://registrationcenter.intel.com with current support. I have confirmed that your test case compiles successfully with this compiler. Please let us know if you see any further problems.

0 Kudos
Reply