Skip to content

Contiguous pointer to type component #14

@ivan-pi

Description

@ivan-pi

For the following program

integer, parameter :: sp = kind(1.0e0)
type :: d1
  real(sp) :: val
end type
type(d1), target :: b(5)
real(sp), pointer, contiguous :: c(:)
b%val = 1.0_sp
c => b%val
end

flang, nvfortran, and nagfor accept it.

gfortran raises an error:

/app/example.f90:8:5:

    8 | c => b%val
      |     1
Error: Assignment to contiguous pointer from non-contiguous target at (1)

ifx raises an error:

/app/example.f90(8): error #8377: An array is not contiguous if any part other than final has non-zero rank.   [VAL]
c => b%val
-------^
/app/example.f90(8): error #8371: If pointer is declared CONTIGUOUS, target must be contiguous as well.   [VAL]
c => b%val
-------^
compilation aborted for /app/example.f90 (code 1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions