the issue comes from floating point stack being too precise on ix86. for example the following ------------------------------------- #include <stdio.h> int f(double d) { d *= 100; return d; } int main() { printf("%d\n", f(0.099999999999999992)); return 0; } --------------------------------------- gives - 9 with -02 on i586 - 10 on all other arches - 10 with -02 -ffloat-store on i586 the patch uses "volatile" to ensure the equivalent of -ffloat-store on the part of the code that needs it Signed-off-by: Pascal Rigaux <pixel@mandriva.com> diff -p -up php-5.2.5/Zend/zend_strtod.c.pix php-5.2.5/Zend/zend_strtod.c --- php-5.2.5/Zend/zend_strtod.c.pix 2008-01-31 15:07:55.000000000 +0100 +++ php-5.2.5/Zend/zend_strtod.c 2008-02-01 12:07:28.000000000 +0100 @@ -984,7 +984,7 @@ static Bigint * diff(Bigint *a, Bigint * static double ulp (double _x) { - _double x; + volatile _double x; register Long L; _double a; @@ -1092,7 +1092,7 @@ static Bigint * d2b(double _d, int *e, i Bigint *b; int de, i, k; ULong *x, y, z; - _double d; + volatile _double d; #ifdef VAX ULong d0, d1; #endif @@ -1213,7 +1213,7 @@ static Bigint * d2b(double _d, int *e, i static double ratio (Bigint *a, Bigint *b) { - _double da, db; + volatile _double da, db; int k, ka, kb; value(da) = b2d(a, &ka); @@ -1480,7 +1480,7 @@ ZEND_API char * zend_dtoa(double _d, int Bigint *b, *b1, *delta, *mlo, *mhi, *S, *tmp; double ds; char *s, *s0; - _double d, d2, eps; + volatile _double d, d2, eps; value(d) = _d; @@ -2043,7 +2058,7 @@ ZEND_API double zend_strtod (CONST char e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; CONST char *s, *s0, *s1; double aadj, aadj1, adj; - _double rv, rv0; + volatile _double rv, rv0; Long L; ULong y, z; Bigint *bb, *bb1, *bd, *bd0, *bs, *delta, *tmp;