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

            Bug ID: 122397
           Summary: Wrong dtype passing inquiry ref of complex array to
                    pointer dummy with INTENT(IN)
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

Consider:

program test
  implicit none
  complex, target :: z(3) = [(1,-1),(2,-2),(3,-3)]
  real,   pointer :: p(:)
  p => z%re
  call sub (p)
  call sub (z%re) ! <<< wrong dtype!
contains
  subroutine sub (x)
    real, pointer, intent(in) :: x(:)
    print *, x
  end subroutine sub
end program test

The indicated line passes a descriptor with the wrong dtype:
(e.g. for gcc-14, for trunk after the fix for pr122386; before there was an
unwanted temporary):

    struct array01_complex(kind=4) parm.2;

    parm.2.span = 8;
    parm.2.dtype = {.elem_len=8, .version=0, .rank=1, .type=4};
    parm.2.dim[0].lbound = 1;
    parm.2.dim[0].ubound = 3;
    parm.2.dim[0].stride = 1;
    parm.2.data = (void *) &z[0];
    parm.2.offset = -1;
    sub (&parm.2);

It should be:

    struct array01_real(kind=4) parm.2;
    parm.2.dtype = {.elem_len=4, .version=0, .rank=1, .type=3};

etc.

Reply via email to