[Bug libfortran/31286] New: cshift uses uninitialized variables
burnus at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Tue Mar 20 19:23:00 GMT 2007
As found by Salvatore Filippone using valgrind.
-----------------------
program testcshft
integer :: alist(4)
!!$alist = (/1,2,3,4/)
alist =cshift(alist,-1)
write(*,*) alist
end program testcshft
-------------------------
==6801== Conditional jump or move depends on uninitialised value(s)
> ==6801== at 0x1B98AF30: cshift0 (cshift0.c:193)
> ==6801== by 0x8048673: MAIN__
Analysis by me:
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 array, sstride gets never initialized.
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;
--
Summary: cshift uses uninitialized variables
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: wrong-code, patch
Severity: normal
Priority: P3
Component: libfortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: burnus at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31286
More information about the Gcc-bugs
mailing list