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]

FW: GNU f77 bug report


Dear GNU f77,

   The program listed at the end of this message (iabtst--both .f and .r 
versions are included) runs as expected without the -O option but appears
to encounter an infinite loop with the -O option.  Further details are

1.  The problem occurs with input parameters a=0 and b=3 (for example).

2.  I'm running ecgs-2.90.29 980515 egcs-1.03 release under Redhat linux
version 5.2 on a 500 Mhz Pentium III, using the default installation 
parameters.

3.  I get no warning messages with the -W, -Wall, or -Wuninitialized flags.

4.  The code runs properly with the options -O -fno-automatic or
-O -ffloat-store, but not with -O -finit-local-zero.

5.  I suspect that the problem has to do with the while statements
of the form

while (t1 != t1o)
   {...}

where t1 and t1o are real*8.

The .r and .f versions of the code follow.

Thanks,

Brent


.r version:

program iabtst

   implicit real*8 (a-h,o-z)
   real*8 iab
   common /iabcmn/ cf1,cf2,niab

   cf1=3.0d0/5.0d0
   cf2=1.0d0
   niab=0
   repeat
      {
      write (6,*) 'enter a,b'
      read (5,*) a,b
      if (a == -999.0d0) stop
      viab=iab(a,b)
      write (6,*) a,b,viab
      }
end
real*8 function iab(a,b)

   implicit real*8 (a-h,o-z)
   common /iabcmn/ cf1,cf2,niab

   a24=min(a,b)**2/4.0d0
   b24=max(a,b)**2/4.0d0
   t1=cf1*ps1(a24,b24)
   t2=cf2*ps2(a24,b24)
   t3=cf2*ps3(a24,b24)
   iab=t1+t2+t3
   return

end
real*8 function ps1(a24,b24)

   implicit real*8 (a-h,o-z)

   t1=0.0d0
   t1o=-999.0d0
   c1=1.0d0
   c2=1.0d0
   m1=0
   while (t1 != t1o)
      {
      t1o=t1
      t2=0.0d0
      t2o=-999.0d0
      c3=1.0d0
      c4=c2
      m2=0
      while (t2 != t2o)
	 {
	 t2o=t2
	 t2=t2+c3*c4
	 c3=c3*b24/(m2+1)**2
	 c4=c4*(1.0d0+m1+m2)/(1.0d0/6.0d0+m1+m2)
	 m2=m2+1
	 }
      t1=t1+c1*t2
      c1=c1*a24/(m1+1)**2
      c2=c2*(1.0d0+m1)/(1.0d0/6.0d0+m1)
      m1=m1+1
      }
   ps1=t1
   return

end
real*8 function ps2(a24,b24)

   implicit real*8 (a-h,o-z)

   ps2=0.0d0
   if (b24 == 0.0d0) return
   t1=0.0d0
   t1o=-999.0d0
   c1=1.0d0
   c2=1.0d0
   m1=0
   while (t1 != t1o)
      {
      t1o=t1
      t2=0.0d0
      t2o=-999.0d0
      c3=1.0d0
      c4=c2
      m2=0
      while (t2 != t2o)
	 {
	 t2o=t2
	 t2=t2+c3*c4
	 c3=c3*b24/(11.0d0/6.0d0+m2)**2
	 c4=c4*(11.0d0/6.0d0+m1+m2)/(m1+m2+1.0d0)
	 m2=m2+1
	 }
      t1=t1+c1*t2
      c1=c1*a24/(m1+1)**2
      c2=c2*(11.0d0/6.0d0+m1)/(m1+1.0d0)
      m1=m1+1
      }
   t2=b24**(5.0d0/6.0d0)*t1
   ps2=t2
   return

end
real*8 function ps3(a24,b24)

   implicit real*8 (a-h,o-z)

   ps3=0.0d0
   if (b24 == 0.0d0) return
   t1=0.0d0
   t1o=-999.0d0
   c1=1.0d0
   m1=0
   while (t1 != t1o)
      {
      t1o=t1
      t2=0.0d0
      t2o=-999.0d0
      c3=(a24/b24)*(-5.0d0/6.0d0)**2/(m1+1.0d0)**2
      m2=1
      while (t2 != t2o)
	 {
	 t2o=t2
	 t2=t2+c3
	 c3=c3*(a24/b24)*(m2-5.0d0/6.0d0)**2/(m1+m2+1.0d0)**2
	 m2=m2+1
	 }
      t1=t1+c1*t2
      c1=c1*a24*(11.0d0/6.0d0+m1)/(m1+1.0d0)**3
      m1=m1+1
      }
   t3=b24**(5.0d0/6.0d0)*t1
   ps3=t3
   return

end


.f version:

      program iabtst
      implicit real*8 (a-h,o-z)
      real*8 iab
      common /iabcmn/ cf1,cf2,niab
      cf1=3.0d0/5.0d0
      cf2=1.0d0
      niab=0
23000 continue
      write (6,*) 'enter a,b'
      read (5,*) a,b
      if(.not.(a .eq. -999.0d0))goto 23003
      stop
23003 continue
      viab=iab(a,b)
      write (6,*) a,b,viab
23001 goto 23000
23002 continue
      end
      real*8 function iab(a,b)
      implicit real*8 (a-h,o-z)
      common /iabcmn/ cf1,cf2,niab
      a24=min(a,b)**2/4.0d0
      b24=max(a,b)**2/4.0d0
      t1=cf1*ps1(a24,b24)
      t2=cf2*ps2(a24,b24)
      t3=cf2*ps3(a24,b24)
      iab=t1+t2+t3
      return
      end
      real*8 function ps1(a24,b24)
      implicit real*8 (a-h,o-z)
      real*8 m1,m2
      t1=0.0d0
      t1o=-999.0d0
      c1=1.0d0
      c2=1.0d0
      m1=0
23000 if(.not.(t1 .ne. t1o))goto 23001
      t1o=t1
      t2=0.0d0
      t2o=-999.0d0
      c3=1.0d0
      c4=c2
      m2=0
23002 if(.not.(t2 .ne. t2o))goto 23003
      t2o=t2
      t2=t2+c3*c4
      c3=c3*b24/(m2+1)**2
      c4=c4*(1.0d0+m1+m2)/(1.0d0/6.0d0+m1+m2)
      m2=m2+1
      goto 23002
23003 continue
      t1=t1+c1*t2
      c1=c1*a24/(m1+1)**2
      c2=c2*(1.0d0+m1)/(1.0d0/6.0d0+m1)
      m1=m1+1
      goto 23000
23001 continue
      ps1=t1
      return
      end
      real*8 function ps2(a24,b24)
      implicit real*8 (a-h,o-z)
      real*8 m1,m2
      ps2=0.0d0
      if(.not.(b24 .eq. 0.0d0))goto 23004
      return
23004 continue
      t1=0.0d0
      t1o=-999.0d0
      c1=1.0d0
      c2=1.0d0
      m1=0
23006 if(.not.(t1 .ne. t1o))goto 23007
      t1o=t1
      t2=0.0d0
      t2o=-999.0d0
      c3=1.0d0
      c4=c2
      m2=0
23008 if(.not.(t2 .ne. t2o))goto 23009
      t2o=t2
      t2=t2+c3*c4
      c3=c3*b24/(11.0d0/6.0d0+m2)**2
      c4=c4*(11.0d0/6.0d0+m1+m2)/(m1+m2+1.0d0)
      m2=m2+1
      goto 23008
23009 continue
      t1=t1+c1*t2
      c1=c1*a24/(m1+1)**2
      c2=c2*(11.0d0/6.0d0+m1)/(m1+1.0d0)
      m1=m1+1
      goto 23006
23007 continue
      t2=b24**(5.0d0/6.0d0)*t1
      ps2=t2
      return
      end
      real*8 function ps3(a24,b24)
      implicit real*8 (a-h,o-z)
      real*8 m1,m2
      ps3=0.0d0
      if(.not.(b24 .eq. 0.0d0))goto 23010
      return
23010 continue
      t1=0.0d0
      t1o=-999.0d0
      c1=1.0d0
      m1=0
23012 if(.not.(t1 .ne. t1o))goto 23013
      t1o=t1
      t2=0.0d0
      t2o=-999.0d0
      c3=(a24/b24)*(-5.0d0/6.0d0)**2/(m1+1.0d0)**2
      m2=1
23014 if(.not.(t2 .ne. t2o))goto 23015
      t2o=t2
      t2=t2+c3
      c3=c3*(a24/b24)*(m2-5.0d0/6.0d0)**2/(m1+m2+1.0d0)**2
      m2=m2+1
      goto 23014
23015 continue
      t1=t1+c1*t2
      c1=c1*a24*(11.0d0/6.0d0+m1)/(m1+1.0d0)**3
      m1=m1+1
      goto 23012
23013 continue
      t3=b24**(5.0d0/6.0d0)*t1
      ps3=t3
      return
      end




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