This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/52351] New: Wrong bounds when passing an array section to an intent-in pointer dummy


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52351

             Bug #: 52351
           Summary: Wrong bounds when passing an array section to an
                    intent-in pointer dummy
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


The following program should print:
           3           6
           1           4
but it wrongly prints
           3           6
           3           6


The program uses the Fortran 2008 feature that one can pass a nonpointer to an
intent(in) pointer argument.


>From the standard:

"12.5.2.7 Pointer dummy variables"
"If the dummy argument does not have the INTENT (IN), the actual argument shall
be a pointer. Otherwise, the actual argument shall be a pointer or a valid
target for the dummy pointer in a pointer assignment statement. If the actual
argument is not a pointer, the dummy pointer becomes pointer associated with
the actual argument."

"16.5.2 Pointer association"
"If the pointer has deferred type parameters or shape, their values are assumed
from the target."


As lbound(a(:)) == 1 (always) and lbound(a) == 3 (in this example), the
respective result should be obtained for lbound(x).



integer, allocatable, target :: A(:)
allocate(A(3:6))

call sub (a)
call sub (a(:))

contains

  subroutine sub(x)
    integer, pointer, intent(in) :: x(:)
    print *, lbound(x), ubound(x)
  end subroutine sub
end


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]