public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/31286]  New: cshift uses uninitialized variables
@ 2007-03-20 19:23 burnus at gcc dot gnu dot org
  2007-03-23 21:20 ` [Bug libfortran/31286] " fxcoudert at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-20 19:23 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libfortran/31286] cshift uses uninitialized variables
  2007-03-20 19:23 [Bug libfortran/31286] New: cshift uses uninitialized variables burnus at gcc dot gnu dot org
@ 2007-03-23 21:20 ` fxcoudert at gcc dot gnu dot org
  2007-04-17 21:39 ` fxcoudert at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-03-23 21:20 UTC (permalink / raw)
  To: gcc-bugs



-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-03-23 21:20:08
               date|                            |
   Target Milestone|---                         |4.3.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31286


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libfortran/31286] cshift uses uninitialized variables
  2007-03-20 19:23 [Bug libfortran/31286] New: cshift uses uninitialized variables burnus at gcc dot gnu dot org
  2007-03-23 21:20 ` [Bug libfortran/31286] " fxcoudert at gcc dot gnu dot org
@ 2007-04-17 21:39 ` fxcoudert at gcc dot gnu dot org
  2007-04-18  8:47 ` fxcoudert at gcc dot gnu dot org
  2007-04-18  8:53 ` fxcoudert at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-04-17 21:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from fxcoudert at gcc dot gnu dot org  2007-04-17 22:39 -------
Your patch is pre-approved :)


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |burnus at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31286


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libfortran/31286] cshift uses uninitialized variables
  2007-03-20 19:23 [Bug libfortran/31286] New: cshift uses uninitialized variables burnus at gcc dot gnu dot org
  2007-03-23 21:20 ` [Bug libfortran/31286] " fxcoudert at gcc dot gnu dot org
  2007-04-17 21:39 ` fxcoudert at gcc dot gnu dot org
@ 2007-04-18  8:47 ` fxcoudert at gcc dot gnu dot org
  2007-04-18  8:53 ` fxcoudert at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-04-18  8:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from fxcoudert at gcc dot gnu dot org  2007-04-18 09:47 -------
Subject: Bug 31286

Author: fxcoudert
Date: Wed Apr 18 09:47:28 2007
New Revision: 123944

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123944
Log:
        PR libfortran/31286
        PR libfortran/31296

        * intrinsics/cshift0.c (cshift0): Initialize sstride[0] and rstride[0].
        * intrinsics/unpack_generic.c (unpack0, unpack0_char): Zero the
        array structures we pass to unpack_internal.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/ChangeLog-2004
    trunk/libgfortran/ChangeLog-2005
    trunk/libgfortran/ChangeLog-2006
    trunk/libgfortran/intrinsics/cshift0.c
    trunk/libgfortran/intrinsics/unpack_generic.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31286


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libfortran/31286] cshift uses uninitialized variables
  2007-03-20 19:23 [Bug libfortran/31286] New: cshift uses uninitialized variables burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-04-18  8:47 ` fxcoudert at gcc dot gnu dot org
@ 2007-04-18  8:53 ` fxcoudert at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-04-18  8:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from fxcoudert at gcc dot gnu dot org  2007-04-18 09:53 -------
Fixed on mainline.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31286


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-04-18  8:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-20 19:23 [Bug libfortran/31286] New: cshift uses uninitialized variables burnus at gcc dot gnu dot org
2007-03-23 21:20 ` [Bug libfortran/31286] " fxcoudert at gcc dot gnu dot org
2007-04-17 21:39 ` fxcoudert at gcc dot gnu dot org
2007-04-18  8:47 ` fxcoudert at gcc dot gnu dot org
2007-04-18  8:53 ` fxcoudert at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).