[Bug c/31734] optimizer looses ops for with aliasing
ebotcazou at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Sat Apr 28 15:53:00 GMT 2007
------- 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
More information about the Gcc-bugs
mailing list