------- Comment #1 from ebotcazou at gcc dot gnu dot org  2007-04-28 16:53 
-------
> #if 0
>   /* abuse union to cast (long double) to int[] - but it works */
>   result.value = value;
>   out->fraction = result.array[0];
>   out->mantissa = result.array[1] & 0x7fffffff;
> #else
>   /* this is odd, using ((int*)&value)[0] fools the optimizer
>    * and it omits the previous 2 ops on value!
>    */
>   out->fraction = ((int*)&value)[0];
>   out->mantissa = ((int*)&value)[1] & 0x7fffffff;
> #endif

Nothing odd, the latter code violates the C aliasing rules.  The former code
is the right way to do this kind of low-level fiddling, see the entry for
-fstrict-aliasing in the manual.


-- 

ebotcazou at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31734

Reply via email to