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

* [Bug fortran/56615] [4.6/4.7/4.8 Regression] Wrong code with TRANSFER of arrays of character with stride -1
  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 ` burnus at gcc dot gnu.org
  2013-03-14 21:05 ` burnus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-03-14 18:01 UTC (permalink / raw)
  To: gcc-bugs


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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |4.1.2, 4.3.4
           Keywords|                            |wrong-code
   Last reconfirmed|                            |2013-03-14
                 CC|                            |burnus at gcc dot gnu.org
     Ever Confirmed|0                           |1
            Summary|[4.4/4.5/4.6/4.7            |[4.6/4.7/4.8 Regression]
                   |Regression] Wrong code for  |Wrong code with TRANSFER of
                   |passing arrays of character |arrays of character with
                   |                            |stride -1
   Target Milestone|---                         |4.6.4
      Known to fail|                            |4.4.0, 4.5.3, 4.6.3, 4.7.2,
                   |                            |4.8.0

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-03-14 18:01:06 UTC ---
The problem seems to be the TRANSFER in:

  call cmp (a(n:1:-1), t)
...
  subroutine cmp (b, s)
    character(len=1), dimension(:), intent(in) :: b
    c = TRANSFER (b, c)



In the dump, I see code like:

__builtin_memcpy (transfer.5, parm.4.data, MAX_EXPR
<MIN_EXPR<D.1912,D.1904>,0>);


However, that assumes that parm.4.data is contiguous and walked forwardly. In
4.4, one has the same - but additionally the calls:

D.929 = _gfortran_internal_pack (&parm.4);
...
_gfortran_internal_unpack (&parm.4, D.929);


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

* [Bug fortran/56615] [4.6/4.7/4.8 Regression] Wrong code with TRANSFER of arrays of character with stride -1
  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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-03-14 21:05 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-03-14 21:04:44 UTC ---
trans-intrinsic.c gfc_conv_intrinsic_transfer's has:

      /* Repack the source if not a full variable array.  */
      if (arg->expr->expr_type == EXPR_VARIABLE
              && arg->expr->ref->u.ar.type != AR_FULL)
        {

However, I do not see any relation between being a full array and the need to
repack. A more useful check would be whether the expression is simply
contiguous or not.


--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -5436,7 +5436,6 @@ gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr *
expr)
       source_type = gfc_get_element_type (TREE_TYPE (argse.expr));

-      /* Repack the source if not a full variable array.  */
-      if (arg->expr->expr_type == EXPR_VARIABLE
-             && arg->expr->ref->u.ar.type != AR_FULL)
+      /* Repack the source if not simply contiguous.  */
+      if (!gfc_is_simply_contiguous (arg->expr, false))
        {
          tmp = gfc_build_addr_expr (NULL_TREE, argse.expr);


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

* [Bug fortran/56615] [4.6/4.7/4.8 Regression] Wrong code with TRANSFER of arrays of character with stride -1
  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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-03-15 10:10 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-03-15 10:09:44 UTC ---
Author: burnus
Date: Fri Mar 15 10:09:39 2013
New Revision: 196675

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196675
Log:
2013-03-15  Tobias Burnus  <burnus@net-b.de>

        PR fortran/56615
        * trans-intrinsic.c (gfc_conv_intrinsic_transfer): Pack arrays
        if they are not simply contiguous.

2013-03-15  Tobias Burnus  <burnus@net-b.de>

        PR fortran/56615                                                        
        * gfortran.dg/transfer_intrinsic_5.f90: New.                            


Added:
    trunk/gcc/testsuite/gfortran.dg/transfer_intrinsic_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/56615] [4.6/4.7/4.8 Regression] Wrong code with TRANSFER of arrays of character with stride -1
  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
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-03-15 12:06 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-03-15 12:05:55 UTC ---
Author: burnus
Date: Fri Mar 15 12:05:45 2013
New Revision: 196676

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196676
Log:
2013-03-15  Tobias Burnus  <burnus@net-b.de>

        PR fortran/56615
        * trans-intrinsic.c (gfc_conv_intrinsic_transfer): Pack arrays
        if they are not simply contiguous.

2013-03-15  Tobias Burnus  <burnus@net-b.de>

        PR fortran/56615
        * gfortran.dg/transfer_intrinsic_5.f90: New.


Added:
    branches/gcc-4_7-branch/gcc/testsuite/gfortran.dg/transfer_intrinsic_5.f90
Modified:
    branches/gcc-4_7-branch/gcc/fortran/ChangeLog
    branches/gcc-4_7-branch/gcc/fortran/trans-intrinsic.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/56615] [4.6/4.7/4.8 Regression] Wrong code with TRANSFER of arrays of character with stride -1
  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
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-03-15 12:07 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-03-15 12:06:24 UTC ---
Author: burnus
Date: Fri Mar 15 12:06:08 2013
New Revision: 196677

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196677
Log:
2013-03-15  Tobias Burnus  <burnus@net-b.de>

        PR fortran/56615
        * trans-intrinsic.c (gfc_conv_intrinsic_transfer): Pack arrays
        if they are not simply contiguous.

2013-03-15  Tobias Burnus  <burnus@net-b.de>

        PR fortran/56615
        * gfortran.dg/transfer_intrinsic_5.f90: New.


Added:
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/transfer_intrinsic_5.f90
Modified:
    branches/gcc-4_6-branch/gcc/fortran/ChangeLog
    branches/gcc-4_6-branch/gcc/fortran/trans-intrinsic.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/56615] [4.6/4.7/4.8 Regression] Wrong code with TRANSFER of arrays of character with stride -1
  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
                   ` (4 preceding siblings ...)
  2013-03-15 12:07 ` burnus at gcc dot gnu.org
@ 2013-03-15 12:09 ` burnus at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-03-15 12:09 UTC (permalink / raw)
  To: gcc-bugs


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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-03-15 12:08:41 UTC ---
FIXED on the 4.8 trunk and on the 4.6 and 4.7 branches.

Thanks for the report!


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