This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: optimization bug gcc 4.1.2
- From: "Andrew Pinski" <pinskia at gmail dot com>
- To: "Fomin Eduard S." <fomin at bionet dot nsc dot ru>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 28 Aug 2008 23:30:27 -0700
- Subject: Re: optimization bug gcc 4.1.2
- References: <48B796DD.6010705@bionet.nsc.ru>
On Thu, Aug 28, 2008 at 11:27 PM, Fomin Eduard S. <fomin@bionet.nsc.ru> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> inline double abs(double x)
> {
> // remove sign bit
> *reinterpret_cast<long long int*>(&x) &= 0x7FFFFFFFFFFFFFFFLL;
...
> This simple code works correct in DEBUG. But it works INCORRECT in
> release (-O2)
You are violating C/C++ aliasing rules, either use a memcpy, an union
or -fno-strict-aliasing.
Thanks,
Andrew Pinski