Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
3 Views

compile error on different kind types

Jump to solution

Someone please have a look at the following code :

module test
    implicit none

    type :: tp
        private
        integer :: a = 0
    end type tp

    interface tp
        module procedure :: func
    end interface tp

    interface
        module function func(var)
            type(tp) :: func
            integer, intent(in) :: var
        end function func
    end interface

    type(tp), parameter :: var1 = tp(1_1)
    type(tp), parameter :: var2 = tp(1_2)
    type(tp), parameter :: var4 = tp(1_4)
    type(tp), parameter :: var8 = tp(1_8)

end module test

submodule(test)  testsub
    implicit none

    contains

    module procedure func
        implicit none

        func % a = var

    end procedure func

end submodule testsub

Only var4 reports an error :

#6259: This array or function or substring is invalid in constant expressions.   [FUNC]
#7715: Replacing invalid structure constructor by integer 1.   [<NULL_STRING>]

why are there different results while parameters only differ in kind types ?

0 Kudos

Accepted Solutions
Highlighted
Valued Contributor II
3 Views

tp(1_4) resolves to func(1_4)

Jump to solution

tp(1_4) resolves to func(1_4); the others don't have the right TKR (specifically K). That means that tp(1_4) invokes a non-intrinsic function so it isn't a constant expression. N2137 C7104.

 

View solution in original post

0 Kudos
2 Replies
Highlighted
Valued Contributor II
4 Views

tp(1_4) resolves to func(1_4)

Jump to solution

tp(1_4) resolves to func(1_4); the others don't have the right TKR (specifically K). That means that tp(1_4) invokes a non-intrinsic function so it isn't a constant expression. N2137 C7104.

 

View solution in original post

0 Kudos
Highlighted
New Contributor I
3 Views

Thanks Repeat Offender, I see

Jump to solution

Thanks Repeat Offender, I see.

 

0 Kudos