Re: [PATCH] zend_operators DVAL_TO_LVAL fix

From: Date: Sat, 11 Sep 2004 00:23:48 +0000
Subject: Re: [PATCH] zend_operators DVAL_TO_LVAL fix
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-12731@lists.php.net to get a copy of this message
Commited. At 09:32 AM 9/10/2004 +0100, Joe Orton wrote:
On Tue, Aug 31, 2004 at 09:48:47PM -0700, Andi Gutmans wrote: It does look as if you're right. I don't quite understand why the standard was written in such a way and not in a way which only makes the value itself undefined. I think we can apply the patch. Does anyone have a problem with setting arbitrary numbers such as LONG_MAX/LONG_MIN for an undefined conversion? I didn't see any objections; so could this be committed? (the patch again below for reference) Index: Zend/zend_operators.c =================================================================== RCS file: /repository/ZendEngine2/zend_operators.c,v retrieving revision 1.194 diff -u -r1.194 zend_operators.c
--- Zend/zend_operators.c       19 Jul 2004 07:19:02 -0000      1.194
+++ Zend/zend_operators.c       27 Aug 2004 12:15:12 -0000
@@ -183,7 +183,15 @@
        }
-#define DVAL_TO_LVAL(d, l) (l) = (d) > LONG_MAX ? (unsigned long) (d) : (long) (d)
+#define DVAL_TO_LVAL(d, l) do {                        \
+       if ((d) > LONG_MAX) {                   \
+               l = LONG_MAX;                   \
+       } else if ((d) < LONG_MIN) {            \
+               l = LONG_MIN;                   \
+       } else {                                \
+               l = (d);                        \
+       }                                       \
+} while (0) #define zendi_convert_to_long(op, holder,
result)                                      \
        if (op==result) { \


« previous php.internals (#12731) next »