public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/56615] New: [4.4/4.5/4.6/4.7 Regression] Wrong code for passing arrays of character
@ 2013-03-14 12:10 anlauf at gmx dot de
  2013-03-14 18:01 ` [Bug fortran/56615] [4.6/4.7/4.8 Regression] Wrong code with TRANSFER of arrays of character with stride -1 burnus at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: anlauf at gmx dot de @ 2013-03-14 12:10 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56615
           Summary: [4.4/4.5/4.6/4.7 Regression] Wrong code for passing
                    arrays of character
    Classification: Unclassified
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: anlauf@gmx.de


Hi,

the code bwloe works with gfortran 4.1.2 and 4.3.4,
but fails at least with 4.4.0, 4.5 and 4.7.

Correct output:
 # Forward:
 a=abcdefgh
 s=abcdefgh
 c=abcdefgh      ok
   stride = +2:
 u=aceg
 c=aceg      ok

 # Backward:
 b=hgfedcba
 t=hgfedcba
 c=hgfedcba      ok
   stride = -1:
 c=hgfedcba      ok

Wrong output:
 # Forward:
 a=abcdefgh
 s=abcdefgh
 c=abcdefgh      ok
   stride = +2:
 u=aceg
 c=abcd    BUG!

 # Backward:
 b=hgfedcba
 t=hgfedcba
 c=hgfedcba      ok
   stride = -1:
 c=hÿÿÿÿ    BUG!

-------------------------------------------

program gfcbug
  implicit none
  integer, parameter             :: n = 8
  integer                        :: i
  character(len=1), dimension(n) :: a, b
  character(len=n)               :: s, t
  character(len=n/2)             :: u

  do i = 1, n
     a(i) = achar (i-1 + iachar("a"))
  end do
  print *, "# Forward:"
  print *, "a=", a
  s = transfer (a, s)
  print *, "s=", s
  call cmp (a, s)
  print *, "  stride = +2:"
  do i = 1, n/2
     u(i:i) = a(2*i-1)
  end do
  print *, "u=", u
  call cmp (a(1:n:2), u)
  print *
  print *, "# Backward:"
  b = a(n:1:-1)
  print *, "b=", b
  t = transfer (b, t)
  print *, "t=", t
  call cmp (b, t)
  print *, "  stride = -1:"
  call cmp (a(n:1:-1), t)
contains
  subroutine cmp (b, s)
    character(len=1), dimension(:), intent(in) :: b
    character(len=*),               intent(in) :: s
    character(len=size(b))                     :: c
    c = transfer (b, c)
    print *, "c=", c, "    ", merge ("  ok","BUG!", c == s)
  end subroutine cmp
end program gfcbug


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

end of thread, other threads:[~2013-03-15 12:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-14 12:10 [Bug fortran/56615] New: [4.4/4.5/4.6/4.7 Regression] Wrong code for passing arrays of character anlauf at gmx dot de
2013-03-14 18:01 ` [Bug fortran/56615] [4.6/4.7/4.8 Regression] Wrong code with TRANSFER of arrays of character with stride -1 burnus at gcc dot gnu.org
2013-03-14 21:05 ` burnus at gcc dot gnu.org
2013-03-15 10:10 ` burnus at gcc dot gnu.org
2013-03-15 12:06 ` burnus at gcc dot gnu.org
2013-03-15 12:07 ` burnus at gcc dot gnu.org
2013-03-15 12:09 ` 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).