Bug 39006 - Wrong result for array(:,ny:1:-1)) as actual argument (inverting order by negative strides)
Summary: Wrong result for array(:,ny:1:-1)) as actual argument (inverting order by n...
Status: RESOLVED DUPLICATE of bug 38852
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.0
: P3 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2009-01-28 17:13 UTC by Tobias Burnus
Modified: 2009-01-28 18:02 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2009-01-28 17:13:19 UTC
Reported by Clive Page, http://gcc.gnu.org/ml/fortran/2009-01/msg00335.html

Fails with gfortran 4.1, 4.2, 4.3 and 4.4, but works with NAG f95, g95, ifort (9.1, 11.0), openf95.

The proper result of the test program is:
------------------------------------------
 normal
   1   2   3   4
  10  20  30  40
 100 200 300 400
 y-inverted
 100 200 300 400    <<<<<<<  These lines
  10  20  30  40    <<<<<<<  are missing
   1   2   3   4    <<<<<<<  with gfortran
------------------------------------------

The program:

!-----------------------------------------
module testy_mod
implicit none
contains
subroutine mysub(text, array)
character(len=*), intent(in) :: text
integer, intent(in) :: array(:,:)
integer :: j
print *, text
do j = 1, ubound(array,2)
   print '(10000i4)', array(:,j)
end do
end subroutine mysub
end module testy_mod

program testy
use testy_mod
implicit none
integer, parameter :: nx = 4, ny = 3
integer :: array(nx,ny)
data array / 1,2,3,4, 10,20,30,40, 100,200,300,400 /
call mysub('normal', array)
call mysub('y-inverted', array(:,ny:1:-1))
end program
Comment 1 Paul Thomas 2009-01-28 17:31:02 UTC
This is the same as PR38852 and the fix for that one works for this too.

Paul

*** This bug has been marked as a duplicate of 38852 ***
Comment 2 Paul Thomas 2009-01-28 21:49:09 UTC
Subject: Bug 39006

Author: pault
Date: Wed Jan 28 21:48:53 2009
New Revision: 143743

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143743
Log:
2009-01-28  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38852
	PR fortran/39006
	* trans-intrinsic.c (gfc_conv_intrinsic_bound): Use the array
	descriptor ubound for UBOUND, when the array lbound == 1.

2009-01-28  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38852
	PR fortran/39006
	* gfortran.dg/bound_6.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/bound_6.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/testsuite/ChangeLog

Comment 3 Paul Thomas 2009-02-19 06:43:47 UTC
Subject: Bug 39006

Author: pault
Date: Thu Feb 19 06:43:15 2009
New Revision: 144286

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144286
Log:
2009-02-19  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38852
	PR fortran/39006
	* trans-intrinsic.c (gfc_conv_intrinsic_bound): Use the array
	descriptor ubound for UBOUND, when the array lbound == 1.

2009-02-19  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38852
	PR fortran/39006
	* gfortran.dg/bound_6.f90: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/bound_6.f90
Modified:
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/trans-intrinsic.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog