EGCS bug when passing float NaN?

Roger L Gates rgates@chandlerevans.com
Thu May 6 07:29:00 GMT 1999


The attached code gave different results than I expected
using CYGWIN B20.1 (gcc --version == egcs-2.91.57):

  global: NaN = 7f99999a
  passed: NaN = 7fd9999a

The bit pattern is different inside the subroutine!

I got similar results compiling with -mno-cygwin:

  global: 1.#QNAN0 = 7f99999a
  passed: 1.#QNAN0 = 7fd9999a

Shouldn't the two values be the same?
Is this a bug in egcs or is it in my code?

Using DJGPP v2.02 (gcc --version == 2.8.1)
the passed value equalled the global value.

- Roger L. Gates <rgates@chandlerevans.com>

#include <stdio.h>

union Converter {
      long  l;
      float f;
};
union Converter global;

void pass_float(float f)
{
   union Converter passed;
   passed.f = f;
   (void) printf("global: %f = %lx\n", global.f, global.l);
   (void) printf("passed: %f = %lx\n", passed.f, passed.l);
}   

int main(void)
{
global.l=0x7F99999A; /* IEEE NaN */
pass_float(global.f);
return 0;
}


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list