1.5.12: FPU affected by gethostname call

Dave Korn dave.korn@artimi.com
Wed Feb 23 18:21:00 GMT 2005

-----Original Message-----
>From: cygwin-owner On Behalf Of R.Schulz
>Sent: 23 February 2005 14:28

>the following c++ program (see below) is affected by a strange bug:
>point precision is decreased by uncommenting the call to gethostname(). 

>* if you change the long doubles to normal doubles, values seem to be not
>affected by the gethostname call
>* the resulting values for double precision are equal to the values
>with long doubles in case the gethostname() function is invoked

  I'd bet the -ffloat-store flag makes a difference too.  This is a
well-known issue with x86 floating point implementations:



  To summarize:  inside the FP registers of the cpu, long doubles are stored
in extended (80-bit) precision format.  When these values have to be stored
to memory locations, however, they are truncated to 64 bits.  So you get
different results from a calculation depending if it's entirely done in
registers or if some of the intermediate results need to be spilled to the
stack, or otherwise stored in memory.

  In this case, the FP registers are presumably being saved and restored
owing to the call to gethostname, so that's why removing the call fixes it.

  If you use normal doubles, you're only ever working with 64-bit values, so
that's why changing to doubles gets the same result as long doubles with the
function call uncommented, even if the registers are not in this case
spilled to memory.

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