Quake III's fast inverse square root returns negatives when compiled with gcc -O1 on 64-bit Linux

tetsuoai · x · 2026-09-25

A developer compiled Quake III's famous fast inverse square root with gcc -O1 on 64-bit Linux and got negative results. The culprit: the long pointer cast reads past the float into stack memory, and the low bit of the return address lands in the sign bit — a concrete case of the classic hack's reliance on undefined behavior breaking on modern toolchains.

Original post →

More from Fun

Fun channel →