Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This post is incorrect. The problem is not a bug in GCC, but rather the PHP developers making unwarranted assumptions about the hardware.

The C standard allows compilers to keep floating-point intermediate results in registers; this is both faster, and can give more accurate results. Since it is allowed, GCC does so when IEEE-extended mode is enabled by compiler flags. PHP enabled those flags, so GCC enables IEEE-extended math, and thus keeps results in registers.

There are a couple ways the PHP developers can fix this:

1. Since the code explicitly says it does not work in IEEE-extended mode, they can disable it by adding "-fexcess-precision=standard" (for GCC) or "-fp-model precise" (for ICC) to their CFLAGS.

2. Alternatively, they could compile in C99 mode; C99 changed the floating-point semantics to make IEEE mode the default.

3. They could use the system's strtod() or strtod_l() , which is presumably designed to work on the current architecture.

Finally, regarding the author's suggestion to use Clang: the only reason Clang works as he expects (eg, incorrectly) is because it apparently does not support IEEE-extended math on x87-enabled processors. Suggesting that users switch to a compiler because it is missing features is ridiculous, especially if they add support for this feature later.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: