cygwin gcc: Different numerical results in thread vs in main()

Dave Korn dave.korn@artimi.com
Mon Aug 4 15:54:00 GMT 2008


Richard Stanton wrote on 04 August 2008 15:29:

> Thanks for the helpful information, David. Oddly, -ffloat-store doesn't
> seem to make any difference: 

  No, unfortunately it can't be assumed to; it'll only come into play if the
results get spilled to memory, rather than living in (x87) registers the
whole time.  It's not a very useful workaround as it only fixes some
instances of the problem and not others, and it does so unpredictably
according to optimisation settings, register pressure and context.  It's
only useful as a very limited diagnostic: in those cases where it /does/
make a difference, you can be pretty certain that excess precision is coming
into play, but in those where it makes no difference, you just still don't
know.

  Take a look at the (legendary) GCC PR323:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323

... and in particular comment #60:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323#c60

... which has a bit of code you can adapt (google for the definition of
_FPU_SETCW, it's an inline asm you can copy from linux/x86 headers); using
that to set double precision mode in your thread startup code, and using
double (never float) types throughout your code is probably the best you can
do.


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list