https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96896

            Bug ID: 96896
           Summary: Bogus 'Different ranks in pointer assignment' with
                    'array-variable = scalar' if LHS is a function
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
  Target Milestone: ---

The following program fails with:
  Error: Different ranks in pointer assignment

Function calls returning a pointer are regarded as variable, hence, the
following boils down to
  array_variable = scalar
which should be fine.

program reshape_test
    implicit none
    real, target, dimension (1:9) :: b
    b = 0.0 ! needed otherwise triggers a FIXME
    myshape(b) = 0.0  ! LHS: 3x3 array, RHS: scalar
contains
  function myshape(b)
    real, target, dimension (1:9) :: b
    real, pointer :: myshape(:,:)
    myshape(1:3,1:3) => b
  end function myshape
end program reshape_test

Reply via email to