Catch gcc ±Inf bugs.
Merge pull request #2276 from ibuclaw/noinfbugs

Catch GCC ±Inf bugs.