public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/34770]  New: Incorrect array indexing through pointer when array does not start at 1
@ 2008-01-13 16:18 michalak at ucar dot edu
  2008-01-13 16:32 ` [Bug fortran/34770] " burnus at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: michalak at ucar dot edu @ 2008-01-13 16:18 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-03-01 12:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-13 16:18 [Bug fortran/34770] New: Incorrect array indexing through pointer when array does not start at 1 michalak at ucar dot edu
2008-01-13 16:32 ` [Bug fortran/34770] " burnus at gcc dot gnu dot org
2008-01-13 16:55 ` john at michalakes dot us
2008-03-01 12:21 ` fxcoudert at gcc dot gnu dot org
2008-03-01 12:22 ` fxcoudert at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).