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/33139] array pointer assignment gives incorrect dimensions



------- Comment #3 from burnus at gcc dot gnu dot org  2007-08-22 14:41 -------
Note: for a(:) and thus also for "p=>a(:)" the lbound starts at 1 (this is
somewhere hidden in "6.2.2.3 Array sections") - this part works.

Partial patch. Note: This patch is incomplete as one also needs to set the
offset to 10.

--- trans-array.c       (revision 127689)
+++ trans-array.c       (working copy)
@@ -4766,6 +4766,4 @@ gfc_conv_expr_descriptor (gfc_se * se, g
-         /* If we have an array section or are assigning to a pointer,
-            make sure that the lower bound is 1.  References to the full
-            array should otherwise keep the original bounds.  */
-         if ((!info->ref
-              || info->ref->u.ar.type != AR_FULL
-              || se->direct_byref)
+         /* If we have an array section make sure that the lower bound is 1.
+            References to the full array should otherwise keep the original
+            bounds.  */
+         if ((!info->ref || info->ref->u.ar.type != AR_FULL)



! { dg-do run }
!
! PR fortran/33139
!
program prog
  implicit none
  real, target :: a(-10:10)
  real, pointer :: p(:)
  integer :: i
  do i = -10, 10
    a(i) = real(i)
  end do
  p => a
  if(lbound(p,dim=1) /= -10 .and. ubound(p,dim=1) /= 10) &
    call abort()
  do i = -10, 10
    if(p(i) /= real(i)) call abort()
  end do
  p => a(:)
  if(lbound(p,dim=1) /= 1 .and. ubound(p,dim=1) /= 21) &
   call abort()
end program prog


-- 


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


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