[Bug fortran/13105] New: array slice can return incorrect values and can have incorrect shape
melvin dot hadasht at free dot fr
gcc-bugzilla@gcc.gnu.org
Tue Nov 18 12:57:00 GMT 2003
Using tree-ssa from 2003-11-15, on PII266, linux-2.6.0-test9-mm2, glibc-2.3.2
It looks like slices of arrays of rank 3 have a problem
(I did not do extensive tests on rank 2).
The following test case produces incorrect results:
cat > test_slice.f90 << EOF
program test_slice
implicit none
real (kind = 8), dimension(2, 2, 2) :: x
real (kind = 8) :: min, max
x = 1
print *, 'x(1, 1:2, 1:1)):'
min = minval(x(1, 1:2, 1:1)) ! may not give 1
max = maxval(x(1, 1:2, 1:1)) ! may not give 1
print *, min, max, ":", x(1, 1:2, 1:1) ! not all values are 1
print *, "shape: ", shape(x(1, 1:2, 1:1)) ! returns 1 2 instead of 2 1
print *, 'x(1, 1:2, 1)):'
min = minval(x(1, 1:2, 1)) ! ok but...
max = maxval(x(1, 1:2, 1)) ! ok but..
print *, min, max, ":", x(1, 1:2, 1) ! ok but..
print *, "shape: ", shape(x(1, 1:2, 1)) ! ..error: returns 1 instead of 2
print *, 'x(1:1, 1:2, 1:1)):'
min = minval(x(1:1, 1:2, 1:1)) ! ok
max = maxval(x(1:1, 1:2, 1:1)) ! ok
print *, min, max, ":", x(1:1, 1:2, 1:1) ! ok
print *, "shape:", shape(x(1:1, 1:2, 1:1)) ! ok
end program test_slice
EOF
Returns:
x(1, 1:2, 1:1)):
1.00000000000000 2.08604192733644 : 2.08604192733644
1.00000000000000
shape: 1 2 !!! should be 1 1 : 1 1 and
shape should be 2 1
x(1, 1:2, 1)):
1.00000000000000 1.00000000000000 : 1.00000000000000
1.00000000000000
shape: 1 !! should be 2
x(1:1, 1:2, 1:1)):
1.00000000000000 1.00000000000000 : 1.00000000000000
1.00000000000000
shape: 1 2 1 !! ok
Tested also against VAST-F90 and IFC to confirm expected results.
Fortran version:
/usr/local/gcc-ssa/bin/gfortran -v
Reading specs from
/usr/local/gcc-ssa/bin/../lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/specs
Configured with: /usr/local/src/cvs/gcc/configure
--enable-languages=c,f95,f77,c++,objc --prefix=/usr/local/gcc-ssa :
(reconfigured) /usr/local/src/cvs/gcc/configure
--enable-languages=c,f95,c++,objc --prefix=/usr/local/gcc-ssa
Thread model: posix
gcc version 3.5-tree-ssa 20031115 (merged 20031111)
--
Summary: array slice can return incorrect values and can have
incorrect shape
Product: gcc
Version: tree-ssa
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: melvin dot hadasht at free dot fr
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13105
More information about the Gcc-bugs
mailing list