This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/29516] New: Bug in character transpose


The following program (adapted from our testsuite):

$ cat char_transpose_1.f90 
program main
  implicit none
  integer, parameter :: n1 = 3, n2 = 4, slen = 9
  character (len = slen), dimension (n1, n2) :: a
  integer :: i1, i2

  do i2 = 1, n2
    do i1 = 1, n1
      a (i1, i2) = 'ab'(i1:i1) // 'cde'(i2:i2) // 'cantrip'
    end do
  end do

  call test (transpose (a))
contains
  subroutine test (b)
    character (len = slen), dimension (:, :) :: b

    print *, size (b, 1), "==", n2
    print *, size(b,2), "==", n1

    do i2 = 1, n2
      do i1 = 1, n1
        print *, b (i2, i1), "==", a (i1, i2)
      end do
    end do
  end subroutine test
end program main

gives incorrect results on i386-apple-darwin, with both -m32 and -m64:

$ gfortran char_transpose_1.f90 -g -m32 && ./a.out
           4 ==           4
           4 ==           3
 accantrip==accantrip
 adcantrip==bccantrip
 aecantrip==cccantrip
 adcantrip==adcantrip
 aecantrip==bdcantrip
 aacantrip==cdcantrip
 aecantrip==aecantrip
 aacantrip==becantrip
 ,��l���==cecantrip
 aacantrip==aacantrip
 ,��l���==bacantrip
 �""==cacantrip
$ gfortran char_transpose_1.f90 -m64 && ./a.out
           4 ==           4
           4 ==           3
 accantrip==accantrip
 adcantrip==bccantrip
 aecantrip==cccantrip
 adcantrip==adcantrip
 aecantrip==bdcantrip
 aacantrip==cdcantrip
 aecantrip==aecantrip
 aacantrip==becantrip
 �==cecantrip
 aacantrip==aacantrip
 �==bacantrip
 ���==cacantrip


This is with mainline gfortran:

$ gfortran -v
Using built-in specs.
Target: i386-apple-darwin8.8.1
Configured with: /gcc/configure --enable-languages=c,fortran
Thread model: posix
gcc version 4.2.0 20061019 (experimental)


The corresponding test results can be found here:
http://gcc.gnu.org/ml/gcc-testresults/2006-10/msg00952.html (and they don't
look too good).


-- 
           Summary: Bug in character transpose
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fxcoudert at gcc dot gnu dot org
GCC target triplet: i386-apple-darwin8.8.1


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]