This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

Re: optimization bug gcc 4.1.2


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


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