[Bug fortran/21480] New: trivial reshape operation gives erroneous results

kamaraju at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon May 9 23:04:00 GMT 2005


$cat reshape_bug.f90
program reshape_bug
 implicit none
 integer, parameter :: NX = 2
 complex :: a(0:NX-1)

 a(:) = cmplx(0.0, 0.0)
 write(*,*) 'before'
 write(*,*) a(:)
 a(0:NX-1) = reshape(a(0:NX-1), (/NX/))
 write(*,*) 'after'
 write(*,*) a(:)
end program reshape_bug

$gfortran-snapshot reshape_bug.f90

$./a.out
 before
 (  0.000000    ,  0.000000    ) (  0.000000    ,  0.000000    )
 after
 (  0.000000    ,  0.000000    ) (  2.022202    ,  0.000000    )

The program changes the value of a(2) once reshape function is executed. But
infact a(2) should just remain as (  0.000000    ,  0.000000    ).

Using debian, sid.
$gfortran-snapshot -v
Using built-in specs.
Target: i486-linux
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,ada,treelang
--prefix=/usr/lib/gcc-snapshot --enable-shared --with-system-zlib --disable-nls
--program-suffix=-20050507-1 --enable-__cxa_atexit
--enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug
--enable-java-gc=boehm --enable-java-awt=gtk --enable-mpfr --disable-werror
--disable-werror i486-linux
Thread model: posix
gcc version 4.1.0 20050507 (experimental)

-- 
           Summary: trivial reshape operation gives erroneous results
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kamaraju at gmail dot com
                CC: gcc-bugs at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list