Is there a PR open for this code?

jdelia@intec.unl.edu.ar jdelia@intec.unl.edu.ar
Thu Sep 11 14:36:00 GMT 2008


Dear all,

Using the compilers

$ gfortran  --version
GNU Fortran (GCC) 4.4.0 20080302 (experimental) [trunk revision 132813]
Copyright (C) 2007 Free Software Foundation, Inc.

$ ifort --version
ifort (IFORT) 9.0  20051201

Here there are some experiments:

1) With "test31.f90"

$ gfortran -Wuninitialized -o test31.exe test31.f90
f951: warning: -Wuninitialized is not supported without -O
$ gfortran -Wuninitialized -O1 -o test31.exe test31.f90
test31.f90: In function 'no_leak':
test31.f90:5: warning: 'i' is used uninitialized in this function
test31.f90:5: warning: 'n' is used uninitialized in this function
$ gfortran -Wall -o test31.exe test31.f90
$ test31.exe
Segmentation fault
$ ifort -warn all -o test31.exe test31.f90
fortcom: Warning: test31.f90, line 5: This name has not been given an  
explicit type.   [N]
   x=(/(i, i=1, n)/)
---------------^
$ test31.exe
   0.0000000E+00

2) And with "test32.f90"

$ gfortran -Wuninitialized -o test32.exe test32.f90
f951: warning: -Wuninitialized is not supported without -O
$ gfortran -Wuninitialized -O1 -o test32.exe test32.f90
$ test32.exe
    0.0000000
$ gfortran -Wall -o test32.exe test32.f90
$ test32.exe
    0.0000000
$ ifort -warn all -o test32.exe test32.f90
$ test32.exe
   0.0000000E+00


Where

$cat test31.f90

program no_leak1
   real, dimension(100) :: x, y
   x=(/(i, i=1, n)/)
   y(:size(compact(x))) = compact(x)**2
   print *, y(n)
   contains
     function compact(x)
       real, allocatable, dimension(:) :: compact
       real, dimension(:), intent(in) :: x
       integer :: n
       n = size(x)
       allocate(compact(n))
     end function compact
end program

$cat test32.f90

program no_leak2
   implicit none
   integer, parameter :: n = 100
   real, dimension(n) :: x, y
   integer :: i
   x=(/(i, i=1, n)/)
   y(:size(compact(x))) = compact(x)**2
   print *, y(n)
   contains
     function compact(x)
       real, allocatable, dimension(:) :: compact
       real, dimension(:), intent(in) :: x
       integer :: n
       n = size(x)
       allocate(compact(n))
     end function compact
end program
---

Regards
Jorge.

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



More information about the Fortran mailing list