public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "scottb at uci dot edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/17077] New: adjustable size arrays crash
Date: Wed, 18 Aug 2004 09:55:00 -0000	[thread overview]
Message-ID: <20040818095446.17077.scottb@uci.edu> (raw)

Using adjustable size arrays in subroutines causes some memory alloc problem. 
It crashes my system, other times results in gibberish output.  

I have put a program below that fails.  It works on other f90 compilers.

WORKAROUND: When I replace adjustable size arrays (e.g. x(n,n)) with assumed
size arrays (e.g., x(:,:)) it all works fine. No idea why.

I use Mac OS X 10.3 (Darwin6.8) on dual G5. 
GCC version 3.5-tree-ssa-lno 20040811 (merged 20040718).
Configured with /gcc/configure --enable-threads=posix --enable-languages=c,f95


!Program that fails.
program p
implicit none
integer:: n
   n=3
   call foo(n)
   
contains
  subroutine foo(m)
    integer:: m,i
    real, dimension(m,m):: z
      ! Print z. It's OK here (all zero).
      do i=1,m
	write(*,*) z(i,:)
      enddo
      call foo1(z)
  end subroutine foo

  subroutine foo1(x)
    integer:: n,i,j
    real, dimension(:,:):: x
      ! Print z. It's not OK here (memory garbage).
      do i=1,n
	write(*,*) x(i,1:n)
      enddo
  end subroutine foo1
    
end program p

-- 
           Summary: adjustable size arrays crash
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: scottb at uci dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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


             reply	other threads:[~2004-08-18  9:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-18  9:55 scottb at uci dot edu [this message]
2004-08-19  0:27 ` [Bug fortran/17077] " jvdelisle at verizon dot net
2004-08-20 13:31 ` cvs-commit at gcc dot gnu dot org
2004-08-20 13:34 ` pbrook at gcc dot gnu dot org
2004-08-20 15:37 ` pinskia 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=20040818095446.17077.scottb@uci.edu \
    --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).