[Bug fortran/49324] New: iso_varying_string and reshape fail
jjcogliati-r1 at yahoo dot com
gcc-bugzilla@gcc.gnu.org
Wed Jun 8 15:07:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49324
Summary: iso_varying_string and reshape fail
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jjcogliati-r1@yahoo.com
Iso varying string seems to fail with reshape.
I am using the iso_varying_string module available from
http://www.fortran.com/iso_varying_string.f95
My test case is:
!--------------
program test_ivs
use iso_varying_string
implicit none
type(varying_string),dimension(:,:),allocatable :: array2d
type(varying_string) :: extra
integer :: i,j
allocate(array2d(2,3))
extra = "four"
array2d(:,:) = reshape((/ var_str("1"), &
var_str("2"), var_str("3"), &
extra, var_str("5"), &
var_str("six") /), (/ 2, 3 /))
print *,"array2d second ",ubound(array2d),(("'"//char(array2d(i,j))//"'
",i=1,size(array2d,1)),j=1,size(array2d,2))
end program test_ivs
!-----------------
With this test case, I get the output:
array2d second 2 3 '' '0' 'P' 'P!&' '0' '!&'
If I modify it to:
!---------------------
program test_ivs_no_reshape
use iso_varying_string
implicit none
type(varying_string),dimension(:,:),allocatable :: array2d
type(varying_string) :: extra
integer :: i,j
allocate(array2d(2,3))
extra = "four"
array2d(:,1) = (/ var_str("1"), var_str("2") /)
array2d(:,2) = (/ var_str("3"), extra /)
array2d(:,3) = (/ var_str("5"), var_str("six") /)
print *,"array2d first ",ubound(array2d),(("'"//char(array2d(i,j))//"'
",i=1,size(array2d,1)),j=1,size(array2d,2))
end program test_ivs_no_reshape
!------------------
I get the following output:
array2d first 2 3 '1' '2' '3' 'four' '5' 'six'
which is what I expected.
$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/home/jjc/gcc/gcc_460_install/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.6.0/configure --prefix=/home/jjc/gcc/gcc_460_install/
Thread model: posix
gcc version 4.6.0 (GCC)
Compiling:
$ gfortran -Wall -c iso_varying_string.f95
$ gfortran -Wall -o test_ivs.f90 test_ivs.f90 iso_varying_string.o
$ ./test_ivs
array2d second 2 3 '' '0' 'P' 'PQ�' '0' 'Q�'
More information about the Gcc-bugs
mailing list