This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: problem with alias-safe code


Mark Mitchell <mark@markmitchell.com> writes:

> Oh, dear.  I always get bogged down in these GCC extensions.  I'm sure
> there's a good reason for them, but in this case why not just write:
> 
>   double my_fabs (double x)
>   {
>     union u_t { double d; int i[2]; };
>     ((union u_t*) &x)->i[1] &=  0x7fffffff;
>     return x;
>   }

This works in the given case but in general such a construct is used
with an arbitrary value for the floating point value.  The situation
is that I need macros which extracts from a given floating point value
the words.  The FP value can be a memory location like in the fabs
example, but it could also be a rvalue.  The gcc extension makes sure
it works in either case.

-- 
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]