[PATCH] fix KJS crash on some more strict platforms

Maks Orlovich mo002j at mail.rochester.edu
Tue Dec 16 23:51:32 GMT 2003


On Tuesday 16 December 2003 06:41 pm, Helge Deller wrote:
> On Wednesday 17 December 2003 00:30, Maks Orlovich wrote:
> > > The compiler might align char[] and double in _this_ example
> > > differently, e.g. char[] at a 2 byte boundary and double at 8 bytes.
> > > Look at the manpage of gcc (e.g.
> > > http://scv.bu.edu/SCV/Archive/linux-cluster/manpages/gcc.html and
> > > search for the example in the description for "-fstrict-aliasing"): "In
> > > particular, an object of one type is assumed never to reside at the
> > > same address as an object of a different type, unless the types are
> > > almost the same. For example, an "unsigned int" can alias an "int", but
> > > not a "void*" or a "double""
> > >
> > > char[] and double are not "almost the same".
> >
> > Ahem. Read a bit further. "A character type may alias any other type. "
> >

> And this is exactly what my proposed patch is about. We try to read a
> double from the pointer which is &char[8] and this is not guaranteed to
> work: const double NaN = *(const double*) NaN_Bytes;

Yes, but that has nothing to do w/using a union to initialize it. 





More information about the kde-core-devel mailing list