Re: be used uninitialized in this function



On 15 jan, 15:44, Jinsong Zhao <jsz...@xxxxxxxx> wrote:
Hi there,

With the example code below, gfortran (4.5.0) give a strange warning
message with -O2 flag:

 > gfortran -Wall -O2 -c readmo.f90
readmo.f90: In function 'readmo':
readmo.f90:4:0: warning: 'convrt' may be used uninitialized in this function

When with -O0, the warning message disappear.

In fact, the array lopt is not initialized in the code, however, the
compiler does not give warning about that.

Any suggestions or comments? Thanks in advance!

Regards,
Jinsong

subroutine readmo()
!!!! example code readmo.f90 !!!!

    implicit none
    real :: convrt
    integer :: i, iflag, j
    integer, dimension(3,5) :: lopt

    iflag = 0
    do i = 1, 5
       do j = 1, 3
          if ( lopt(j,i) < 0 ) then
             convrt = 1.0
             if ( j > 1 ) convrt = 2.0
             iflag = 1
          endif
       enddo
    enddo
    if ( iflag /= 0 ) then
       do i = 1, 5
          write(6,*) i*convrt
       enddo
    endif

end subroutine readmo

For me, lopt seems to be seen as a function returning an integer of
dimension (3,5).
In that case lopt must be missing at link time.

.



Relevant Pages

  • Re: Snow warning, but from where?
    ... I'd have more  money then the head of UKMO John Hirst. ... If you look at the detailed warning, ...     I've just looked at the offending maps and warnings; they have not ... warning for any part of what the Met Office calls the southeast for ...
    (uk.sci.weather)
  • Re: Making the case for "typed" lists/iterators in python
    ... collections that share a single type ... accessing multiple elements via a common interface ...   class ValarrayWrapper: ... I don't think that a warning helps people write correct code, ...
    (comp.lang.python)
  • Re: Returning a value from another application
    ... of the variable warning from the excel module to Access ... Dim fName As String ...     For RCOUNT = RCOUNT To LastRow ...
    (microsoft.public.access.formscoding)
  • Re: Required Fields and Warning Boxes
    ... email field needs to be completed before the form can ... warning box to appear asking the user "are you sure you want to make ... and if I click OK it updates. ...     return true; ...
    (comp.lang.javascript)
  • Re: what is the output of this program?
    ... I tried to compile and run it myself, but my compiler (lcc-win32) ... Warning test2.c: 3  ' ...   The function main does not match the expected type. ... different places not separated by a sequence point constraining evaluation ...
    (comp.lang.c)