another 64-bit issue

Steve Kargl sgk@troutmask.apl.washington.edu
Wed Aug 25 22:18:00 GMT 2004


On Wed, Aug 25, 2004 at 02:42:18PM -0700, Steve Kargl wrote:
> On Wed, Aug 25, 2004 at 02:27:40PM -0700, Steve Kargl wrote:
> > Consider this program
> > 
> >   program t
> >    real(8) y
> >    print*, 'huge(y) = ', huge(y)
> >   end program t
> > 
> > on my 64-bit amd64 FreeBSD system.  The compiled
> > program hangs without printing any thing to stdout.
> > I've traced the problem with gdb and it appears
> > that the line
> > 
> > calculate_exp (d=15) at ../../../gcc/libgfortran/io/write.c:143
> > spins in an infinite loop.
> > 
> 
> I misread the gdb trace.  The problem may be in output_float().
> 

Yep, the problem is in output_float().  I sprinkled some
printfs in it and found that

line 288:  sca = g.scale_factor;
line 289:  n = value;

gives

sca   = 1
n     = 1.79769313486231571e+308
value = 1.79769313486231571e+308

We next end up inside the 

  if (ft == FMT_F || ft == FMT_E || ft == FMT_D)

block with "sca = 1", which means this block 
is executed

      /* Calculate the new val of the number with consideration
         of global scale value.  */
      while (sca >  0)
        {
          minv *= 10.0;
          maxv *= 10.0;
          n *= 10.0;
  printf("%.17e\n", n);
          sca -- ;
          neval --;

and we get "n = inf", which is not a Good Thing..

-- 
Steve



More information about the Fortran mailing list