public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libfortran/31286]  New: cshift uses uninitialized variables
Date: Tue, 20 Mar 2007 19:23:00 -0000	[thread overview]
Message-ID: <bug-31286-13404@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2007-03-20 19:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-20 19:23 burnus at gcc dot gnu dot org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-31286-13404@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).