This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/77365] New: Wrong result with -fcaller-saves on i386
- From: "olebole at debian dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 24 Aug 2016 12:31:46 +0000
- Subject: [Bug c/77365] New: Wrong result with -fcaller-saves on i386
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77365
Bug ID: 77365
Summary: Wrong result with -fcaller-saves on i386
Product: gcc
Version: 6.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: olebole at debian dot org
Target Milestone: ---
With gcc-6.2.0 on Debian, I get a wrong result with the following code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double f(double x) {
return sqrt(1.0 - x) - 1.0;
}
double g(double x) {
double res = f(x);
printf("res=%.20g\n", res);
return res;
}
int main(void) {
double x = 3.1740879016271733482e-09;
double r1 = f(x);
double r2 = g(x);
printf("r1=%.20g r2=%.20g diff=%20g\n", r1, r2, r2-r1);
exit(0);
}
Compile this with `gcc -O -o m m.c -lm` gives
r =-1.5870439520936432953e-09
r1=-1.5870439407095204842e-09 r2=-1.5870439520936432953e-09 diff=
-1.13841e-17
Adding `-fno-caller-saves` gives the expected result.