This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: cshift & uninitialized
- From: Tobias Burnus <burnus at net-b dot de>
- To: salvatore dot filippone at uniroma2 dot it
- Cc: Fortran at gcc dot gnu dot org
- Date: Tue, 20 Mar 2007 15:27:12 +0100
- Subject: Re: cshift & uninitialized
- References: <1174398503.3869.10.camel@localhost.localdomain>
Hi,
Salvatore Filippone wrote:
> Now the real strange thing: if I uncomment the initialization and run
> through valgrind, I get the following:
>
> ==6801== Conditional jump or move depends on uninitialised value(s)
> ==6801== at 0x1B98AF30: cshift0 (cshift0.c:193)
> ==6801== by 0x8048673: MAIN__
>
alist =cshift(alist,-1)
This calls cshift0(ret, array, shift, which, size)
where size = GFC_DESCRIPTOR_RANK (array)
and "which" is the dimension (not given -> 1)
Thus: which == size == 1.
In cshift0 one finds:
which = which - 1;
for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
{
if (dim == which) { ... }
else
{ sstride[n] = ... }
}
if (sstride[0] == 0)
That is: If which == rank of the arry, sstride gets never initialized.
The following patch should fix this. (I don't have the time to check the
other "if"s nor to submit the patch currently, though.)
Tobias
Index: libgfortran/intrinsics/cshift0.c
===================================================================
*** libgfortran/intrinsics/cshift0.c (revision 123083)
--- libgfortran/intrinsics/cshift0.c (working copy)
*************** cshift0 (gfc_array_char * ret, const gfc
*** 103,108 ****
--- 103,110 ----
runtime_error ("Argument 'DIM' is out of range in call to 'CSHIFT'");
which = which - 1;
+ sstride[0] = 0;
+ rstride[0] = 0;
extent[0] = 1;
count[0] = 0;