- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I‘ve encountered a derived-type constructor selection issue and the compiler reported an error which seemed non-relevant. The sample code is as follows:
module test implicit none private public :: var type :: tp private integer(8) :: var1 logical :: var2 = .false. end type tp interface tp module procedure :: init end interface tp interface module function init(var) type(tp) :: init integer, intent(in) :: var end function init end interface integer(8), parameter :: default = 10 type(tp), parameter :: var = tp(default, .false.) end module test
The error message is:
error #6050: This parameter was defined too late. [DEFAULT]
If tp and init interfaces are removed, the code can be compiled with no errors. Appreciate any help.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The interface declares var as integer and not integer(8) but if that is the problem the message is strange!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks andrew. Unfortunately it's not the problem. As you suggested, I made some corrections to the sample.
And in addition, if the default value is set literally, it's all right.
module test implicit none private public :: var type :: tp private integer(8) :: var1 logical :: var2 = .false. end type tp interface tp module procedure :: init end interface tp interface module function init(var) type(tp) :: init integer(8), intent(in) :: var end function init end interface integer(8), parameter :: default = 10_8 !type(tp), parameter :: var = tp(default, .false.) ! <--- Bad. type(tp), parameter :: var = tp(10_8, .false.) ! <--- Good. end module test
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks like a compiler bug, deserving of submission at the Intel Online Service Center/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I agree - the definition of the user constructor init is confusing the compiler. I don't see anything wrong with the code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks FortranFan and Steve, I'll report it to OSC.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page