A Bug of gfortran, g77 and g95 on default optimization

Steve Kargl sgk@troutmask.apl.washington.edu
Mon Jun 18 18:01:00 GMT 2007


On Mon, Jun 18, 2007 at 06:54:52PM +0200, Tobias Burnus wrote:
> Tobias Burnus wrote:
> > Sunjoong Lee wrote:
> >   
> >> I had traced side effects of optimization levels for the legacy program;
> >>    -O0 level and -O1 level were different
> >>    but from -O1 to -O3 gave same (wrong) results on gfortran, g77 and
> >> g95.
> >>    I tested it with pgi fortran and got same (right) results.
> >>     
> 
> Follow up: I can reproduce this on my Pentium M with FX's nightly build
> (4.3.0) and SUSE's 4.2.1; I failed to reproduce the problem on x86-64
> even using -m32 and according to Dominique it does not occur on PPC either.
> 
> The problem is tracked as
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32391
> 

ftnchek reports a large number of potential problems with
mixed mode math.  Things of the form:

    352          armsd=dsqrt(rms/L)
                      ^
Warning near line 352 col 15 file TMalign.f: dble expr DSQRT(RMS/L) truncated
 to real ARMSD

 T(1)+U(1,1)*XA(1,I,0)+U( .. truncated to real AX
    461             ay=t(2)+u(2,1)*xa(1,i,0)+u(2,2)*xa(2,i,0)+u(2,3)*xa(3,i,0)
                                  ^
Warning near line 461 col 27 file TMalign.f: promotion may not give desired
 precision: dble U * real XA

troutmask:sgk[211] ftnchek TMalign.f | grep "desired precision" | wc -l
      95

Noting that "desired precision" might be split across a line, 

troutmask:sgk[215] ftnchek TMalign.f | grep "precision" | wc -l
     233

This looks suspicious

Warning in module SUPER_ALIGN in file TMalign.f: Variables may be used before
 set:
    TM_OLD used at line 597 file TMalign.f
    TM_OLD set at line 600 file TMalign.f

This isn't a good idea

   2307       if (sigma .ge. 0.0) goto 52
                        ^
Warning near line 2307 col 17 file TMalign.f: comparison mixes terms of

Warning: Subprogram U3B argument arrayness mismatch at position 2:
    Dummy arg X in module U3B line 2082 file TMalign.f has 2 dims size 3
    Actual arg R_1 in module TMSCORE line 1907 file TMalign.f has 2 dims size 
 15000
  and at position 3:
    Dummy arg Y in module U3B line 2082 file TMalign.f has 2 dims size 3
    Actual arg R_2 in module TMSCORE line 1907 file TMalign.f has 2 dims size 
 15000

In fact, ftnchek finds
troutmask:sgk[217] ftnchek TMalign.f | grep Warning | wc -l
     324

I suspect that is yet another version of PR 323.

-- 
Steve



More information about the Fortran mailing list