This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
gcc 4.4.3, generating code that shows NAN on Solaris 8 (Sparc)
- From: "David Mathog" <mathog at caltech dot edu>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 02 Jun 2011 14:50:54 -0700
- Subject: gcc 4.4.3, generating code that shows NAN on Solaris 8 (Sparc)
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@caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech