Skip to content

class(*), allocatable stole my sequence type #347

@ivan-pi

Description

@ivan-pi

Given a sequence type stored in an unlimited polymorphic variable, the compiler doesn't approve of even a single method to access the data:

! seq_type.f90

type :: seq_type
   sequence
   real :: val
end type

class(*), allocatable :: a

a = seq_type(val=3.0)

select type(a)
type is (seq_type)
    print *, a%val
end select

block
    type(seq_type) :: b
    call move_alloc(from=a,to=b)
    print *, b%val
end block

block
    type(seq_type) :: b
    b = transfer(a, b)
    print *, b%val
end block

end
~> nagfor sequence_upv.f90 
NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7203
Error: sequence_upv.f90, line 14: TYPE IS specifies SEQUENCE type SEQ_TYPE
Error: sequence_upv.f90, line 20: Expected an ALLOCATABLE variable for argument TO (no. 2) of intrinsic MOVE_ALLOC
Warning: sequence_upv.f90, line 26: Intrinsic TRANSFER from polymorphic data object might have partially undefined result
[NAG Fortran Compiler error termination, 2 errors, 1 warning]

This is a corner case of the discussions in,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions