I don't know if this is a bug in gcc or the glibc... Consider the
following program "traps1":

#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include <fenv.h>

int main (int argc, char *argv[])
{
  volatile long double x, y = 0.0;

  if (argc != 3)
    {
      fprintf (stderr, "Usage: exception <double> <flag>\n");
      exit (1);
    }

  if (fesetround (FE_DOWNWARD))
    {
      fprintf (stderr, "Can't set rounding mode to FE_DOWNWARD\n");
      exit (1);
    }

  x = atof (argv[1]);
  x *= LDBL_MAX;
  printf ("x = %Lg\n", x);
  feenableexcept (FE_OVERFLOW);
  if (atoi (argv[2]))
    y += 0.0;
  return 0;
}


I get the following results on X86 and PowerPC processors with gcc 4.0
(Debian):
  * x86, traps1 2 0  -> x = 1.18973e+4932
  * x86, traps1 2 1  -> ditto with floating point exception signal
  * ppc, both cases  -> x = 1.79769e+308 with FPE signal

I don't think one should get floating-point exception signals, and in
any case, the results between both processors seem to be inconsistent.

-- 
Vincent Lefèvre <[EMAIL PROTECTED]> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA

Reply via email to