Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Constructor interface with class pointer function return bug

$
0
0

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:   [I] , 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

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>