public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/27895]  New: problem with SPREAD and zero-sized arrays
@ 2006-06-05  7:07 fxcoudert at gcc dot gnu dot org
  2006-06-05  9:20 ` [Bug fortran/27895] " fxcoudert at gcc dot gnu dot org
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-06-05  7:07 UTC (permalink / raw)
  To: gcc-bugs

The following code gives compile-time warnings that are wrong, and segfaults at
runtime:

module foo_mod
implicit none
contains
pure function outerprod(a,b)
real, intent(in) :: a(:),b(:)
real             :: outerprod(size(a),size(b))
outerprod = spread(a,dim=2,ncopies=size(b)) * spread(b,dim=1,ncopies=size(a))
end function outerprod
end module foo_mod

program xouterprod
use foo_mod, only: outerprod
implicit none
integer, parameter :: i = 4, m = 4, n = 4, l = 5
real               :: aa(m,i),tempn(n)
call random_seed()
aa          = 1.0
tempn       = 2.0
aa(i:m,l:n) = aa(i:m,l:n)+outerprod(aa(i:m,i),tempn(l:n)) ! tricky
print*,aa
end program xouterprod

$ gfortran a.f90
 In file a.f90:19

aa(i:m,l:n) = aa(i:m,l:n)+outerprod(aa(i:m,i),tempn(l:n)) ! tricky
      1
Warning: Array reference at (1) is out of bounds
 In file a.f90:19

aa(i:m,l:n) = aa(i:m,l:n)+outerprod(aa(i:m,i),tempn(l:n)) ! tricky
                                                   1
Warning: Array reference at (1) is out of bounds
 In file a.f90:19

aa(i:m,l:n) = aa(i:m,l:n)+outerprod(aa(i:m,i),tempn(l:n)) ! tricky
                    1
Warning: Array reference at (1) is out of bounds
$ ./a.out
zsh: segmentation fault  ./a.out


-- 
           Summary: problem with SPREAD and zero-sized arrays
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: wrong-code, diagnostic
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fxcoudert at gcc dot gnu dot org


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


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

end of thread, other threads:[~2006-12-01  0:09 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-05  7:07 [Bug fortran/27895] New: problem with SPREAD and zero-sized arrays fxcoudert at gcc dot gnu dot org
2006-06-05  9:20 ` [Bug fortran/27895] " fxcoudert at gcc dot gnu dot org
2006-06-05  9:25 ` [Bug libfortran/27895] " fxcoudert at gcc dot gnu dot org
2006-06-05 13:46 ` fxcoudert at gcc dot gnu dot org
2006-06-05 14:24 ` fxcoudert at gcc dot gnu dot org
2006-06-05 16:23 ` fxcoudert at gcc dot gnu dot org
2006-06-05 22:44 ` fxcoudert at gcc dot gnu dot org
2006-06-19 12:34 ` fxcoudert at gcc dot gnu dot org
2006-06-20  6:07 ` fxcoudert at gcc dot gnu dot org
2006-06-24 23:08 ` fxcoudert at gcc dot gnu dot org
2006-07-26  8:35 ` fxcoudert at gcc dot gnu dot org
2006-10-19 21:49 ` fxcoudert at gcc dot gnu dot org
2006-10-19 21:59 ` [Bug libfortran/27895] problem with RESHAPE " fxcoudert at gcc dot gnu dot org
2006-11-03  7:34 ` fxcoudert at gcc dot gnu dot org
2006-11-03 11:51 ` fxcoudert at gcc dot gnu dot org
2006-11-03 12:24 ` [Bug libfortran/27895] [4.1/4.2 only] " fxcoudert at gcc dot gnu dot org
2006-11-12 21:36 ` mmitchel at gcc dot gnu dot org
2006-11-14  6:19 ` fxcoudert at gcc dot gnu dot org
2006-11-14  6:19 ` fxcoudert at gcc dot gnu dot org
2006-11-14  6:24 ` [Bug libfortran/27895] " fxcoudert at gcc dot gnu dot org
2006-12-01  0:09 ` chaoyingfu 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).