This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/34770] New: Incorrect array indexing through pointer when array does not start at 1
- From: "michalak at ucar dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Jan 2008 15:48:41 -0000
- Subject: [Bug fortran/34770] New: Incorrect array indexing through pointer when array does not start at 1
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Have put together a small test program demonstrating the error, which has to do
with indexing of a pointer when the array it points to starts at an index other
than '1'. The test program, gfortran behavior, and the correct (ifort)
behavior
of the program is listed below.
[michalak@qp ~]$ cat showbad.F90
PROGRAM showbad
IMPLICIT NONE
INTEGER, TARGET :: x(0:12)
INTEGER, POINTER :: z(:)
INTEGER i
DO i = 0,12
x(i) = i
ENDDO
z => x
DO i = 0,12
print*,i,x(i),z(i)
ENDDO
END PROGRAM showbad
[michalak@qp ~]$ gfortran showbad.F90
[michalak@qp ~]$ a.out
0 0 56
1 1 <<< 0 <<< wrong
2 2 1
3 3 2
4 4 3
5 5 4
6 6 5
7 7 6
8 8 7
9 9 8
10 10 9
11 11 10
12 12 11
[michalak@qp ~]$ ifort showbad.F90
[michalak@qp ~]$ a.out
0 0 0
1 1 <<< 1 <<< correct
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9 9
10 10 10
11 11 11
12 12 12
-----------------------------------------------------------
John Michalakes, Software Engineer michalak@ucar.edu
NCAR, MMM Division voice: +1 303 497 8199
3450 Mitchell Lane fax: +1 303 497 8181
Boulder, Colorado 80301 U.S.A. cell: +1 720 209 2320
http://www.mmm.ucar.edu/individual/michalakes
-----------------------------------------------------------
--
Summary: Incorrect array indexing through pointer when array does
not start at 1
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: michalak at ucar dot edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34770