From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29384 invoked by alias); 14 Mar 2013 12:10:18 -0000 Received: (qmail 28867 invoked by uid 48); 14 Mar 2013 12:08:59 -0000 From: "anlauf at gmx dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/56615] New: [4.4/4.5/4.6/4.7 Regression] Wrong code for passing arrays of character Date: Thu, 14 Mar 2013 12:10:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gmx dot de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-03/txt/msg01069.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D56615 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=3Dabcdefgh s=3Dabcdefgh c=3Dabcdefgh ok stride =3D +2: u=3Daceg c=3Daceg ok # Backward: b=3Dhgfedcba t=3Dhgfedcba c=3Dhgfedcba ok stride =3D -1: c=3Dhgfedcba ok Wrong output: # Forward: a=3Dabcdefgh s=3Dabcdefgh c=3Dabcdefgh ok stride =3D +2: u=3Daceg c=3Dabcd BUG! # Backward: b=3Dhgfedcba t=3Dhgfedcba c=3Dhgfedcba ok stride =3D -1: c=3Dh=C3=BF=C3=BF=C3=BF=C3=BF BUG! ------------------------------------------- program gfcbug implicit none integer, parameter :: n =3D 8 integer :: i character(len=3D1), dimension(n) :: a, b character(len=3Dn) :: s, t character(len=3Dn/2) :: u do i =3D 1, n a(i) =3D achar (i-1 + iachar("a")) end do print *, "# Forward:" print *, "a=3D", a s =3D transfer (a, s) print *, "s=3D", s call cmp (a, s) print *, " stride =3D +2:" do i =3D 1, n/2 u(i:i) =3D a(2*i-1) end do print *, "u=3D", u call cmp (a(1:n:2), u) print * print *, "# Backward:" b =3D a(n:1:-1) print *, "b=3D", b t =3D transfer (b, t) print *, "t=3D", t call cmp (b, t) print *, " stride =3D -1:" call cmp (a(n:1:-1), t) contains subroutine cmp (b, s) character(len=3D1), dimension(:), intent(in) :: b character(len=3D*), intent(in) :: s character(len=3Dsize(b)) :: c c =3D transfer (b, c) print *, "c=3D", c, " ", merge (" ok","BUG!", c =3D=3D s) end subroutine cmp end program gfcbug