public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dominiq at lps dot ens dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/35743] allocate negative memory for zero-sized WHERE construct
Date: Mon, 31 Mar 2008 15:15:00 -0000	[thread overview]
Message-ID: <20080331151424.3712.qmail@sourceware.org> (raw)
In-Reply-To: <bug-35743-15620@http.gcc.gnu.org/bugzilla/>



------- Comment #2 from dominiq at lps dot ens dot fr  2008-03-31 15:14 -------
The dump shows:

rg0025 (lda, nf1, nf2, nf3, nf5, nf6, mf1, mf2)
{
  integer(kind=4) ubound.9;
...
    D.979 = *nf6;
    D.980 = *nf3;
    D.981 = *nf6;
    D.982 = *nf3;
    D.983 = (1 - D.979) + *nf3;
    num.12 = D.983;
    D.986 = num.12;
    if (D.986 < 0)
      {
        _gfortran_runtime_error (&"Attempt to allocate a negative amount of
memory."[1]{lb: 1 sz: 1});
      }
...
      D.999 = *nf6;
      D.1000 = *nf2;
      D.1001 = *mf1;
      D.1002 = *nf5;
      D.1003 = *mf1;
      atmp.19.dtype = 297;
      atmp.19.dim[0].stride = 1;
      atmp.19.dim[0].lbound = 0;
      atmp.19.dim[0].ubound = *nf2 - D.999;
      D.1014 = (*nf2 - D.999) + 1 <= 0;
      D.1015 = (*nf2 - D.999) + 1;
      D.1016 = D.1014 ? 0 : D.1015 * 4;
      if (D.1016 < 0)
        {
          _gfortran_runtime_error (&"Attempt to allocate a negative amount of
memory."[1]{lb: 1 sz: 1});
        }
...
}

The size

    D.986 = num.12;

should have a check similar to

      D.1016 = D.1014 ? 0 : D.1015 * 4;

in order to avoid the runtime error.


-- 


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


  parent reply	other threads:[~2008-03-31 15:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-28 21:23 [Bug fortran/35743] New: " dick dot hendrickson at gmail dot com
2008-03-29  0:00 ` [Bug fortran/35743] " dfranke at gcc dot gnu dot org
2008-03-31 15:15 ` dominiq at lps dot ens dot fr [this message]
2008-04-01  7:24 ` pault at gcc dot gnu dot org
2008-05-16 21:13 ` pault at gcc dot gnu dot org
2008-05-17  7:12 ` pault at gcc dot gnu dot org
2008-05-17  7:18 ` pault 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=20080331151424.3712.qmail@sourceware.org \
    --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).