[PATCH] fix KJS crash on some more strict platforms

Helge Deller deller at gmx.de
Tue Dec 16 22:50:30 GMT 2003


On Tuesday 16 December 2003 23:32, Adriaan de Groot wrote:
> On Tuesday 16 December 2003 22:08, Helge Deller wrote:
> > 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;
> 
> From LISP systems I've seen, a solution is
> 
> union { char NaN_Bytes[8];
> 	double NaN_Double;
> 	} NaN_Representation;
> 
> which presumably forces the whole union to the alignment of the strictest 
> type. Neater than using a gcc extension.

Newer gcc's (e.g. 3.3.x) does not guarantee that this will work under all circumstances
and would force you to compile with  -fno-strict-aliasing.





More information about the kde-core-devel mailing list