Re: [PATCH] zend_operators DVAL_TO_LVAL fix
| From: | Ard Biesheuvel | Date: | Sat, 11 Sep 2004 13:22:06 +0000 |
| Subject: | Re: [PATCH] zend_operators DVAL_TO_LVAL fix | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-12735@lists.php.net to get a copy of this message | ||
Joe Orton wrote:
The DVAL_TO_LVAL macro is quite weird, I'm not sure exactly what it's supposed to be doing but it probably isn't doing it. If the integral part of d is outside the range of a long, the conversion has undefined behaviour by the C99 standard; an explicit cast makes no difference AFAICT. GCC on IA64 does wierd things with this macro, though I think there's a GCC bug involved there too. This fixes the macro to have well-defined behaviour for all values of 'd', and avoids triggering the GCC bug on IA64 to boot (both PHP users on that platform will be happy):This probably has to do with the fact that on 64-bit systems, doubles lack the accuracy to distinguish LONG_MAX from LONG_MAX +1. To be on the safe side here, you might want to use >= LONG_MAX instead of > LONG_MAX, or cast the other way around. -- Ard