optimization/10258: byteswapping code fails in -O2
Falk Hueffner
falk.hueffner@student.uni-tuebingen.de
Fri Mar 28 22:26:00 GMT 2003
The following reply was made to PR optimization/10258; it has been noted by GNATS.
From: Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
To: warren_baird@cimmetry.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: optimization/10258: byteswapping code fails in -O2
Date: 28 Mar 2003 23:15:44 +0100
warren_baird@cimmetry.com writes:
> FLOAT swapFLOAT(FLOAT f)
> {
> FLOAT ret;
> DWORD* pDW = (DWORD*)&ret;
> *pDW = BYTESWAP_DWORD(*(DWORD*)&f);
You're violating aliasing constraints here
> printf("0x%08X 0x%08X\n", *(long *)&f1, *(long *)&sf1);
and here. So this is not a gcc bug. Please read the documentation of
-fstrict-aliasing.
--
Falk
More information about the Gcc-prs
mailing list