- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 ?
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Repeat Offender, I see.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page