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/21104] New: Segmentation fault on correct code


The following reduced program causes a segmentation fault at runtime.  It runs 
correctly if the *x on line 11 is removed.  From this, I would surmise that 
something is not right with the allocation of space for the temporary.  Further 
simplification of the structure of the program eliminates the fault; eg. making 
the function public and moving the expression from the subroutine to the main 
program works correctly.

A quick look with -fdump-tree-original indicates that, in the faulty case, no 
memory is allocated to the function output and its pointer remains NULL.

I have tried putting an explicit interface for generalized_hookes_law in the 
subroutine perdida but this has no effect.

$ cat test_intr.f90
!
!      Copyright (C) 1997 by Quetzal Computational Associates, Inc.
!
module perdida_m
    private :: generalized_hookes_law
    public  :: perdida
    integer, parameter, private  :: LONGreal = selected_real_kind (15, 90)

contains

  subroutine perdida (z, x)
    real (kind = LONGreal), dimension (:,:), intent (inOUT) :: z
    real (kind = LONGreal), dimension (:,:), intent (inOUT) :: x
    z = generalized_hookes_law (x) * x
  end subroutine perdida

  function generalized_hookes_law (x) result (z)
    real (kind = LONGreal), dimension (3,3) :: z
    real (kind = LONGreal), dimension (:,:), intent (in) :: x
    z = x
  end function generalized_hookes_law

end module perdida_m

program iztaccihuatl
  use perdida_m
  integer, parameter  :: LONGreal = selected_real_kind (15, 90)
  real (kind = LONGreal)   ::  x(3,3) = 42.0_LONGreal
  real (kind = LONGreal)   ::  y(3,3)
  call perdida (y, x)
end program iztaccihuatl
THOMASP@PC-THOMAS-P /cygdrive/d/gfortran
$ d:/check/bin/gfortran -std=f95 test_intr.f90

THOMASP@PC-THOMAS-P /cygdrive/d/gfortran
$ ./a
Segmentation fault (core dumped)

-- 
           Summary: Segmentation fault on correct code
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: paulthomas2 at wanadoo dot fr
                CC: Thomas dot Koenig at online dot de,gcc-bugs at gcc dot
                    gnu dot org


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


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