public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/52117] New: allocated arrays give incorrect results when used with RESHAPE in gcc v4.6.2
@ 2012-02-03 20:32 sphirshman at yahoo dot com
  2012-02-03 20:43 ` [Bug fortran/52117] " burnus at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: sphirshman at yahoo dot com @ 2012-02-03 20:32 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52117
           Summary: allocated arrays give incorrect results when used with
                    RESHAPE in gcc v4.6.2
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: sphirshman@yahoo.com


This snippet of code gives incorrect results for the reshaped array. If the
arrays are NOT allocated, but explicitly dimensioned, the correct result is
obtained.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      PROGRAM RESHAPEIT

      INTEGER, PARAMETER :: n1=2, n2=2, n3=2
      INTEGER            :: m1, m2, m3, lc
      REAL, ALLOCATABLE  :: A(:,:), B(:,:,:)
      REAL               :: val

      ALLOCATE (A(n1,n2*n3), B(n1,n2,n3))

!     INITIALIZE A
      val = 0
      lc = 0
     DO m3=1,n3
         DO m2=1,n2
            lc = lc+1
            DO m1=1,n1
               val = val+1
               A(m1, lc) = val         
            END DO
         END DO
      END DO

      B = RESHAPE(A, SHAPE(B))

      lc = 0
      DO m3=1,n3
         DO m2=1,n2
            lc = lc+1
            DO m1=1,n1
               PRINT *,'A(',m1,',',lc,') = ',A(m1,lc),' B = ',B(m1,m2,m3)
            END DO
         END DO
      END DO

      DEALLOCATE(A, B)

      PAUSE

      END PROGRAM RESHAPEIT
++++++++++++++++++++++++++++++++++++++++++++++++++++++


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

end of thread, other threads:[~2012-02-11 12:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-03 20:32 [Bug fortran/52117] New: allocated arrays give incorrect results when used with RESHAPE in gcc v4.6.2 sphirshman at yahoo dot com
2012-02-03 20:43 ` [Bug fortran/52117] " burnus at gcc dot gnu.org
2012-02-06 15:38 ` sphirshman at yahoo dot com
2012-02-06 17:47 ` burnus at gcc dot gnu.org
2012-02-06 19:47 ` sphirshman at yahoo dot com
2012-02-06 20:02 ` burnus at gcc dot gnu.org
2012-02-07 11:44 ` hirshmansp at ornl dot gov
2012-02-07 14:37 ` burnus at gcc dot gnu.org
2012-02-07 16:18 ` sphirshman at yahoo dot com
2012-02-10 20:01 ` sphirshman at yahoo dot com
2012-02-10 20:45 ` kargl at gcc dot gnu.org
2012-02-11 11:41 ` burnus at gcc dot gnu.org
2012-02-11 12:08 ` sphirshman at yahoo dot com

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).