This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/31732] [4.3 regression] Assignment to array slice affects whole array
- From: "tkoenig at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Apr 2007 10:23:13 -0000
- Subject: [Bug fortran/31732] [4.3 regression] Assignment to array slice affects whole array
- References: <bug-31732-14475@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from tkoenig at gcc dot gnu dot org 2007-04-28 11:23 -------
The zeroing is done by memset, as the slightly reduced test case shows:
$ cat test2.f90
program Test
implicit none
real, dimension (2,2) :: smooth_factor
data smooth_factor /4*1.0/
smooth_factor(1,:) = 0.
print *, smooth_factor
end program
$ gfortran -fdump-tree-original test2.f90
$ ./a.out
0.000000 0.000000 0.000000 0.000000
$ cat test2.f90.003t.original
MAIN__ ()
{
static real4 smooth_factor[4] = {1.0e+0};
_gfortran_set_std (68, 127, 0, 0, 0);
(void) __builtin_memset ((void *) &smooth_factor, 0, 16);
{
struct __st_parameter_dt dt_parm.0;
dt_parm.0.common.filename = "test2.f90";
dt_parm.0.common.line = 7;
dt_parm.0.common.unit = 6;
dt_parm.0.common.flags = 128;
_gfortran_st_write (&dt_parm.0);
{
struct array2_real4 parm.1;
parm.1.dtype = 282;
parm.1.dim[0].lbound = 1;
parm.1.dim[0].ubound = 2;
parm.1.dim[0].stride = 1;
parm.1.dim[1].lbound = 1;
parm.1.dim[1].ubound = 2;
parm.1.dim[1].stride = 2;
parm.1.data = (void *) &smooth_factor[0];
parm.1.offset = 0;
_gfortran_transfer_array (&dt_parm.0, &parm.1, 4, 0);
}
_gfortran_st_write_done (&dt_parm.0);
}
}
This is probably a result from
2006-12-20 Roger Sayle <roger@eyesopen.com>
* trans-expr.c (is_zero_initializer_p): Determine whether a given
constant expression is a zero initializer.
(gfc_trans_zero_assign): New function to attempt to optimize
"a(:) = 0.0" as a call to __builtin_memset (a, 0, sizeof(a));
(gfc_trans_assignment): Special case array assignments to a
zero initializer constant, using gfc_trans_zero_assign.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31732