[PATCH] fix KJS crash on some more strict platforms

Shaheed srhaque at iee.org
Tue Dec 16 22:13:19 GMT 2003


On Tuesday 16 December 2003 21:08, Helge Deller wrote:
> Some platforms are pretty strict about the alignment for some types
> of variables.
>
> Code like this (taken from kdelibs/kjs/internal.cpp):
> const unsigned char NaN_Bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 };
> ....
> double x = * (double*) NaN_Bytes;

Isn't this also broken in an endianness sense? Hmmm. I'm not an expert, but 
according to:

http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html

I would suggest something like this (not tested):

const Q_INT64 qNaN = 0x7ff8000000000001LL; // Quiet NaN
const Q_INT64 sNaN = 0x7ff0000000000001LL; // SignallingNaN
...
double x = *(double *)whatever;

Note that you are still makingthe assumption of IEEE754 numbers. Hmm. Does KDE 
run on Vaxes? Maybe its not a problem :-)




More information about the kde-core-devel mailing list