This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/44098] New: -O3 causes quickInvSqrt() to return -inf.
- From: "maister at archlinux dot us" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 May 2010 14:45:49 -0000
- Subject: [Bug c/44098] New: -O3 causes quickInvSqrt() to return -inf.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I have tested the famous quickInvSqrt() algorithm uses in Quake, and it does
not compile correctly when compiling with -O3. It does however work completely
fine when compiling for -O0, -O1 and -O2.
The function goes like so:
float quickInvSqrt(float x)
{
float xhalf = 0.5f*x;
int i = *(int*)&x;
i = 0x5f3759df - (i>>1);
x = *(float*)&i;
x = x*(1.5f - xhalf*x*x);
return x;
}
--
Summary: -O3 causes quickInvSqrt() to return -inf.
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: maister at archlinux dot us
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44098