Bogus "is used uninitialized" warnings

View: New views
2 Messages — Rating Filter:   Alert me  

Bogus "is used uninitialized" warnings

by Dennis Wassel-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi list,

if I compile the attached code with -Wall, 4.4.2 gives the me the
following bogus warnings, while 4.3.[2|3|4] and 4.2.4 don't complain:

test.f90: In function 'test1':
test.f90:10: warning: 'j' is used uninitialized in this function
test.f90: In function 'test2':
test.f90:15: warning: 'i' is used uninitialized in this function

I did spot something fishy in the (pruned) tree-dump:

test2 (integer(kind=4) & n)
{
  integer(kind=4) i;
  loopvar.3 = i;
  i = 1;

}

test1 shows the same thing for i and j, but only complains about j. Am
I following the wrong lead?

test1 (integer(kind=4) & n, integer(kind=4) & m)
{
  integer(kind=4) i;
  integer(kind=4) j;
  {
      integer(kind=4) loopvar.9;
      loopvar.9 = j;
      j = 1;
        {
          if (j > D.1540) goto L.4;
          {
            integer(kind=4) loopvar.8;
            loopvar.8 = i;
            i = 1;

Unless someones proves me wrong, it looks like a (minor) 4.4
regression - shall I file a PR?

Cheers,
Dennis

[test.f90]

PROGRAM test

  CALL test1(2,2)
  CALL test2(2)

CONTAINS
 
  SUBROUTINE test1(N,M)
    INTEGER :: i, j, M, N
    PRINT *, [ ((i, i=1,M), j=1,N) ]
  END SUBROUTINE test1
 
  SUBROUTINE test2(N)
    INTEGER :: i, N
    PRINT *, [(1.0, i=1,N)]
  END SUBROUTINE test2

END PROGRAM test



Re: Bogus "is used uninitialized" warnings

by Steve Kargl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Nov 03, 2009 at 06:30:06PM +0100, Dennis Wassel wrote:
>
> Unless someones proves me wrong, it looks like a (minor) 4.4
> regression - shall I file a PR?

No.  The problem seems to be fixed in trunk.

troutmask:sgk[260] gfc4x -o z -Wall tt.f90
troutmask:sgk[261] gfc4x -o z -Wall -O tt.f90
troutmask:sgk[262] gfc4x -o z -Wall -O2 tt.f90
troutmask:sgk[263] gfc4x -o z -Wall -O3 tt.f90
troutmask:sgk[264] gfortran44 -o z -Wall -O3 tt.f90
tt.f90: In function 'test1':
tt.f90:10: warning: 'j' is used uninitialized in this function
tt.f90: In function 'test2':
tt.f90:15: warning: 'i' is used uninitialized in this function

--
Steve