[PATCH] fix KJS crash on some more strict platforms
Helge Deller
deller at gmx.de
Wed Dec 17 00:02:39 GMT 2003
On Wednesday 17 December 2003 00:51, Maks Orlovich wrote:
> 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.
Ok, agreed.
I'm happy with either solution which fixes the bug as long as it gets fixed :-)
Helge
More information about the kde-core-devel
mailing list