... doesn't work: $ cat foo.f90 program main type foo integer :: i character(len=2) :: c end type foo type(foo), dimension(4) :: a a%i = (/ 12, 2, 3, 10 /) a%c = 'xy' print *,maxval(a%i) print *,maxloc(a%i) call bar(a%i) contains subroutine bar(b) integer, dimension(:) :: b print *,b end subroutine bar end program main $ gfortran foo.f90 $ ./a.out 68 3 12 3 68 0
Reduced testcase due to Paul Thomas: $ cat > goo.f90 program main type foo integer :: i character(len=3) :: c end type foo type(foo), dimension(4), target :: a a%i = (/ 12, 2, 3, 10 /) print *, a%i end program main $ gfortran goo.f90 $ ./a.out 12 3 68 0 Confirmed.
gfortran 4.2: struct foo a[4]; int4 A.1[4]; struct array1_int4 atmp.0; [...] static int4 data.3[4] = {12, 2, 3, 10}; __builtin_memcpy (&(*(int4[0:] *) atmp.0.data)[0], &data.3, 16); [...] a[NON_LVALUE_EXPR<S.4>].i = (*(int4[0:] *) atmp.0.data)[NON_LVALUE_EXPR<S.4>]; gfortran 4.3: struct foo a[4]; static int4 A.1[4] = {12, 2, 3, 10}; (void) __builtin_memcpy ((void *) &a, (void *) &A.1, 32);
I am just about to commit as 'obvious' a patch that bootstraps and regtests on x86_ia64/FC5 Paul
Subject: Bug 33370 Author: pault Date: Mon Sep 10 07:54:17 2007 New Revision: 128325 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128325 Log: 2007-09-10 Paul Thomas <pault@gcc.gnu.org> PR fortran/33370 * trans-expr.c (copyable_array_p): Add tests that expression is a variable, that it has no subreferences and that it is a full array. (gfc_trans_assignment): Change conditions to suit modifications to copyable_array_p. 2007-09-10 Paul Thomas <pault@gcc.gnu.org> PR fortran/33370 * gfortran.dg/array_memcpy_5.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/array_memcpy_5.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-expr.c trunk/gcc/testsuite/ChangeLog
Fixed under the 'obvious' rule. Paul