This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

[Bug target/46080] [4.4/4.5/4.6 Regression] incorrect precision of sqrtf builtin for x87 arithmetic (-mfpmath=387)


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46080

--- Comment #11 from Paul Zimmermann <zimmerma+gcc at loria dot fr> 2010-10-22 06:56:20 UTC ---
(In reply to comment #10)
> You can use -fno-errno-math if you don't want errno to be set, then there will
> be no calls to sqrtf and all 3 calls should at least when optimizing evaluate
> in extended precision.

indeed with -fno-math-errno I get three identical results on a 64-bit Core 2
with gcc 4.4.4:


tarte% cat bug.c
#include <stdio.h>
#include <math.h>

float x=(float) 2.0;
int main() {
  printf ("%.10f\n%.10f\n%.10f\n",sqrtf(x),sqrtf(x),sqrtf(x));
  return 0;
}
tarte% gcc -mfpmath=387 bug.c -lm
tarte% ./a.out 
1.4142135382
1.4142135382
1.4142135624

tarte% gcc -mfpmath=387 -fno-math-errno bug.c -lm
tarte% ./a.out 
1.4142135624
1.4142135624
1.4142135624

However setting errno should not have side effects on the results.

Paul


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