This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/57798] New: Incorrect handling of sum over first dimension of a product of automatic arrays


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

            Bug ID: 57798
           Summary: Incorrect handling of sum over first dimension of a
                    product of automatic arrays
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stephan.kramer at imperial dot ac.uk

The test code below results in a segfault evaluating the sum() in the print
statement. This is compiling with gfortran 4.8.1 (4.8.1-4ubuntu1 on Ubuntu
Saucy) without any flags. If bounds checking is switched on (-fbounds-check) I
get a bounds violation error with a random number reported for one of the
bounds:

Fortran runtime error: Dimension 1 of array 'func' has extent 2 instead of
4196256

Is this possibly related to the optimisation requested in
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36841 ?




program test
  implicit none

  call sub(2, 11)

  contains

    function func(m, n)
      integer, intent(in):: m,n
      real, dimension(m, n):: func

      func = 0.0

    end function func

    subroutine sub(m, n)
      integer, intent(in):: m, n
      real, dimension(m,n):: y

      y = 0.0
      print *, sum(y*func(m,n), dim=1)

    end subroutine sub

end program test


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]