This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Question on strict aliasing in C.
-------- Original-Nachricht --------
> Datum: Mon, 04 Jul 2011 20:53:00 +0200
> Von: Georg-Johann Lay <avr@gjlay.de>
> An: paul@mad-scientist.net
> CC: Andrew Haley <aph@redhat.com>, gcc-help@gcc.gnu.org
> Betreff: Re: Question on strict aliasing in C.
> Paul Smith wrote:
> > On Mon, 2011-07-04 at 19:17 +0200, Georg-Johann Lay wrote:
> >>>> double copysign (double x, double y)
> >>>> {
> >>>> unsigned short * const px = (unsigned short*)(char*)&x + 3;
> >>>> unsigned short * const py = (unsigned short*)(char*)&y + 3;
> >
> > I don't get why you have the (char*) cast here?
>
> It's not a source of mine. I don't know the reason why it's there.
>
I think it's a very simple reason: The author knew about strict aliasing, and new that "char*"-pointers are somehow special -- so he added char* in an (useless) attempt to correct it ;-)
Axel
--
NEU: FreePhone - kostenlos mobil telefonieren!
Jetzt informieren: http://www.gmx.net/de/go/freephone