reshape is segfaulting the code

Kamaraju Kusumanchi kamaraju@gmail.com
Mon May 9 17:59:00 GMT 2005


Consider the following test code.

program reshape_bug
  implicit none
  integer, parameter :: NX = 2, NY = 2, NZ = 2**4
  integer, parameter :: DPC = kind((1.0D0, 1.0D0))
  complex(DPC) :: fftw_output(0:NX, 0:NY, 0:NZ-1)
  
  fftw_output = cmplx(0.0D0, 0.0D0)
  fftw_output(0:NX-1, 0:NY-1, 0:NZ-1) = reshape( reshape( &
  fftw_output(0:NX-1, 0:NY-1, 0:NZ-1), (/NX*NY, NZ/), &
  order=(/1,2/)), (/NX, NY, NZ/))
end program reshape_bug

This code compiles fine. But it is giving a segmentation fault when
executed. The code compiles fine with ifort 8.1, absoft 8.0 on a
machine running Debian sid.

$gfortran-20050507-1 -v reshape_bug.f90
Driving: gfortran-20050507-1 -v reshape_bug.f90 -lgfortranbegin
-lgfortran -lm -shared-libgcc
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)
 /usr/lib/gcc-snapshot/libexec/gcc/i486-linux/4.1.0/f951
reshape_bug.f90 -quiet-dumpbase reshape_bug.f90 -mtune=i486 -auxbase
reshape_bug -version -o /tmp/cczJFHqq.s
GNU F95 version 4.1.0 20050507 (experimental) (i486-linux)
        compiled by GNU C version 4.1.0 20050507 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
 as -V -Qy -o /tmp/ccuhAMvI.o /tmp/cczJFHqq.s
GNU assembler version 2.15 (i386-linux) using BFD version 2.15
 /usr/lib/gcc-snapshot/libexec/gcc/i486-linux/4.1.0/collect2
--eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2
/usr/lib/crt1.o /usr/lib/crti.o
/usr/lib/gcc-snapshot/lib/gcc/i486-linux/4.1.0/crtbegin.o
-L/usr/lib/gcc-snapshot/lib/gcc/i486-linux/4.1.0
-L/usr/lib/gcc-snapshot/lib/gcc/i486-linux/4.1.0/../../../tmp/ccuhAMvI.o
-lgfortranbegin -lgfortran -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc-snapshot/lib/gcc/i486-linux/4.1.0/crtend.o
/usr/lib/crtn.o

$./a.out
Segmentation fault


Is this is a known bug? If not, can someone reduce the testcase (as it
looks complicated enough already)? I can report the bug if no
reduction is necessary.

thanks
raju



More information about the Fortran mailing list