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!
26747 Discussions

yet another bug(??) in parameterized derived types

may_ka
Beginner
143 Views

Hi  there

the code

Module testmod
  Type, abstract :: myroot(k)
    Integer(4), kind :: k
  End type myroot
  Type, extends(myroot), abstract :: myvec(lb1,ub1)
    Integer(8), len :: lb1=1,ub1
  End type myvec
  Type, extends(myvec) :: myvec_int
    Integer(k) :: val(lb1:ub1)
  End type myvec_int
End Module testmod
Program Test
  use testmod
  Implicit none
  Type(myvec_int(8,:,:)), allocatable :: a
  Allocate(myvec_int(8,ub1=5)::a)
  a%lb1=6
End Program Test

compiles with 17.05, 18.0 and 18.0.1, where from my understanding "a%lb1=6" should yield a compile time error. Is that correct??

Cheers

0 Kudos
4 Replies
Steve_Lionel
Black Belt Retired Employee
143 Views

I agree with you, though I have spent the last 10 minutes or so paging back and forth through the standard to see if I could find the right words.

What I ended up deciding was that type parameters are NOT data-objects, so they can't be assigned to.

may_ka
Beginner
143 Views

Hi Steve,

thanks for looking into the standard.

Interestingly the compile time error comes up when changing the code to:

Module testmod
  Type, abstract :: myroot(k)
    Integer(4), kind :: k
  End type myroot
  ! Type, extends(myroot), abstract :: myvec(lb1,ub1)
  !   Integer(8), len :: lb1=1,ub1
  ! End type myvec
  Type, extends(myroot) :: myvec_int(lb1,ub1)
    Integer(8), len :: lb1=1,ub1
    Integer(k) :: val(lb1:ub1)
  End type myvec_int
End Module testmod
Program Test
  use testmod
  Implicit none
  Type(myvec_int(8,:,:)), allocatable :: a
  Allocate(myvec_int(8,ub1=5)::a)
  a%lb1=8
End Program Test

Cheers

Steve_Lionel
Black Belt Retired Employee
143 Views

That doesn't astonish me. Please report it through the Intel Online Service Center.

Steve_Lionel
Black Belt Retired Employee
143 Views

I was pointed to this:

 C610 (R611) Each part-name except the leftmost shall be the name of a component of the declared type of the preceding part-name.

Type parameters are not components, so this is invalid.

Reply