This is the mail archive of the gcc-prs@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]

optimization/576: gcc performs invalid optimization with float operations.



>Number:         576
>Category:       optimization
>Synopsis:       gcc performs invalid optimization with float operations.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 28 06:56:01 PDT 2000
>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 performs optimizations that are invalid for some
floating-point computations when the rounding direction
is set towards +infinity or -infinity. As shown in
the code example, trivial identities do no longer hold.
>How-To-Repeat:
#include <stdio.h>

const double MAXDOUBLE=1.797693134862315708e+308;
static unsigned int _up = 0x1a3f;

inline  void 
roundUpward()
{
  asm  ("fldcw _up");
}

int
main()
{
  roundUpward();
  
  double a=MAXDOUBLE;
  double b=(-a)*a;
 
  printf("%g %g\n",(-a)*a, b);
  
  printf("%g %g\n", -((-a)*a), -b);
}
>Fix:

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

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