gcc 4.4.3, generating code that shows NAN on Solaris 8 (Sparc)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This test program:

**************test.c***************
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

int main(void){
double dv;

  dv=0.0;
  fprintf(stdout,"DEBUG zero %llX\n",dv);
  dv=log(-1);
  fprintf(stdout,"DEBUG nan  %llX\n",dv);
  dv=log(0);
  fprintf(stdout,"DEBUG -inf %llX\n",dv);
  dv=-log(0);
  fprintf(stdout,"DEBUG  inf %llX\n",dv);

  exit(EXIT_SUCCESS);
}

****************************************** 
On solaris 8 when compiled with Forte 6 C compiler like:

% cc -xlibmieee -lm -o test test.c
% ./test
DBL zero 0
DBL nan  7FFFFFFFFFFFFFFF
DBL -inf FFF0000000000000
DBL  inf 7FF0000000000000

has a working NAN.  Although there is no NAN without xlibmieeee:

% cc -lm -o test test.c
% ./test
DBL zero 0
DBL nan  FFF0000000000000
DBL -inf FFF0000000000000
DBL  inf 7FF0000000000000

On linux the default has a working NAN

% gcc -std=c99 -Wall -lm -o test test.c
% ./test
DBL zero 0
DBL nan  7FF8000000000000
DBL -inf FFF0000000000000
DBL  inf 7FF0000000000000

Unfortunately on Solaris 8, using gcc 4.3.3 NAN is broken:
% /opt/csw/gcc4/bin/gcc -std=c99 -Wall -lm -o test test.c
% ./test
DBL zero 0
DBL nan  FFF0000000000000
DBL -inf FFF0000000000000
DBL  inf 7FF0000000000000

Notice that NAN is indistinguishable from -inf.  Same result for gcc
3.4.6 on this platform.  Is there a gcc switch equivalent to 
Sun's -xlibmieee?

I can code around the missing isinf() FP_NAN etc. (see my other post in
this list from today), but only if the result of the math operations
allows NAN to be determined from the final bit pattern.

Thanks,

David Mathog
mathog@xxxxxxxxxxx
Manager, Sequence Analysis Facility, Biology Division, Caltech


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux