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.
- From: kevin diggs <diggskevin38 at gmail dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 5 Jul 2011 17:56:09 -0500
- Subject: Re: Question on strict aliasing in C.
- References: <4E11F0FC.7020601@gjlay.de> <4E11F35E.6050209@redhat.com>
Hi,
On Mon, Jul 4, 2011 at 12:07 PM, Andrew Haley <aph@redhat.com> wrote:
>
> It's not. ?Tey're wrong, you're right.
>
> Hope this helps. ?:-)
>
> Andrew.
>
What about this:
#include <math.h>
#define MASK ((unsigned short) 0x8000)
double copysign (double x, double y)
{
unsigned short * const py = (unsigned short*)(char*)&y + 3;
return fabs(x)*(*py&MASK?-1.0:1.0);
}
kevin