optimization/2146: Invalid optimization for the exponential function

Frederic.Goualard@cwi.nl Frederic.Goualard@cwi.nl
Fri Mar 2 02:16:00 GMT 2001


>Number:         2146
>Category:       optimization
>Synopsis:       Invalid optimization for the exponential function
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 02 02:16:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Frederic Goualard
>Release:        gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
Red Hat Linux release 6.2 (Zoot)
Kernel 2.2.14-12 on an i686
Environment variables have their default values under this
O.S.
>Description:
GCC optimizes the computation of the exponential
of a constant by replacing the call to the function
provided by the mathematical library by some assembler
instructions to compute it directly.

Without any optimization, the result of exp(-Inf) is correctly
0, but becomes nan whenever one uses the -O1 option or above.
>How-To-Repeat:
#include <stdio.h>
#include <math.h>

int
main()
{
  double a= -1.0/0.0;

  printf("%.16g\n",exp(a));
}

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list