public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/52012] New: [4.6/4.7 Regression] Wrong-code with RESHAPE
@ 2012-01-26 23:14 burnus at gcc dot gnu.org
  2012-01-27  0:13 ` [Bug fortran/52012] " burnus at gcc dot gnu.org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-26 23:14 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52012
           Summary: [4.6/4.7 Regression] Wrong-code with RESHAPE
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: critical
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
                CC: pault@gcc.gnu.org


The following program prints with GCC 4.6 and 4.7:

   0.0000   0.0000   1.0000   0.0000   0.0000
   0.0000   0.0000   0.0000

Expected: The following result - as with GCC 4.5:

   0.0000   0.0000   1.0000   0.0000   0.0000
   0.0000   0.0000   1.0000

Doing a simple   print '(10f3.0)', a  shows the correct result. Thus, depending
how one accesses an array element, the result is correct or wrong.


The issue was reported by Reinhold Bader; I added the abort checks (both fail).


program gf
  implicit none
  real, allocatable :: a(:,:,:)
!  real :: a(5,4,3)
  real :: b(3,4,5) = 0.0
  b(1,2,3) = 1.0
  allocate(a(size(b,3),size(b,2),size(b,1)))
  a = reshape(b,shape(a),order=[3,2,1])
  write(*,*) a(:,2,1)
! the following line prints an incorrect value of a(3,2,1)
! even though the above one works correctly
  write(*,*) a(1,2,1), a(2,2,1), a(3,2,1)
  if (a(3,2,1) /= 1) call abort()
  if (sum(abs(a)) /= 1.0) call abort()
end program


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

end of thread, other threads:[~2012-02-03 20:44 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-26 23:14 [Bug fortran/52012] New: [4.6/4.7 Regression] Wrong-code with RESHAPE burnus at gcc dot gnu.org
2012-01-27  0:13 ` [Bug fortran/52012] " burnus at gcc dot gnu.org
2012-01-27  0:22 ` dominiq at lps dot ens.fr
2012-01-27  0:26 ` [Bug fortran/52012] [4.6/4.7 Regression] Wrong-code with realloc on assignment burnus at gcc dot gnu.org
2012-01-27  9:27 ` rguenth at gcc dot gnu.org
2012-01-27 10:06 ` [Bug fortran/52012] [4.6/4.7 Regression] Wrong-code with realloc on assignment and RESHAPE w/ ORDER= burnus at gcc dot gnu.org
2012-01-27 10:54 ` jakub at gcc dot gnu.org
2012-01-30 22:21 ` pault at gcc dot gnu.org
2012-01-30 23:16 ` burnus at gcc dot gnu.org
2012-01-31  9:47 ` paul.richard.thomas at gmail dot com
2012-01-31 12:52 ` pault at gcc dot gnu.org
2012-01-31 12:56 ` [Bug fortran/52012] " pault at gcc dot gnu.org
2012-01-31 13:02 ` pault at gcc dot gnu.org
2012-01-31 14:32 ` [Bug fortran/52012] [4.6/4.7 Regression] " burnus at gcc dot gnu.org
2012-02-02 21:20 ` pault at gcc dot gnu.org
2012-02-03 18:35 ` pault at gcc dot gnu.org
2012-02-03 20:42 ` burnus at gcc dot gnu.org
2012-02-03 20:44 ` burnus at gcc dot gnu.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).