Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
25 Views

yet another bug(??) in parameterized derived types

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
Highlighted
Black Belt Retired Employee
25 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.

0 Kudos
Highlighted
Beginner
25 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

0 Kudos
Highlighted
Black Belt Retired Employee
25 Views

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

0 Kudos
Highlighted
Black Belt Retired Employee
25 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.

0 Kudos