[PATCH] fix KJS crash on some more strict platforms
Friedrich W. H. Kossebau
Friedrich.W.H at Kossebau.de
Fri Dec 19 11:18:51 GMT 2003
Am Donnerstag, 18. Dezember 2003 22:20 schrieb Helge Deller:
> This code is at least not very portable.
Oh, what part of the code do you mean by portable? The double alignment
problem? Or something else?
> At the first glance it should work, _as_ _long_ as you ensure
> that "Data" is align on a 8 byte (because of P64Bit) boundary.
> Right now it's aligned anywhere, where the compiler puts it.
>
> Something like:
> typedef union { unsigned char b[8]; double d; } aligned_t;
> aligned_t Data;
> ...
> P8Bit = &Data.b[7];
> P16Bit = &Data.b[6];
> P32Bit = &Data.b[4];
> P64Bit = Data.b[0];
P64Bit = Data.b; // you meant ;)
>
> should be safer.
>
> FYI: I tested khexedit right now on my PA (bigendian) machine and it
> worked correctly.
> But maybe it was just pure luck that the compiler aligned it correctly :-)
To be on the safe side I have applied your solution to khexedit.
Thanks
Friedrich
More information about the kde-core-devel
mailing list