Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

compile error on different kind types

Blane_J_
New Contributor I
116 Views

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
1 Solution
JVanB
Valued Contributor II
116 Views

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

2 Replies
JVanB
Valued Contributor II
117 Views

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

Blane_J_
New Contributor I
116 Views

Thanks Repeat Offender, I see.

 

Reply