Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12420 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83857 invoked by uid 1010); 27 Aug 2004 12:25:53 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 83823 invoked from network); 27 Aug 2004 12:25:52 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by pb1.pair.com with SMTP; 27 Aug 2004 12:25:52 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i7RCPqS0023796 for ; Fri, 27 Aug 2004 08:25:52 -0400 Received: from radish.cambridge.redhat.com (radish.cambridge.redhat.com [172.16.18.90]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i7RCPp314729 for ; Fri, 27 Aug 2004 08:25:51 -0400 Received: from radish.cambridge.redhat.com (localhost.localdomain [127.0.0.1]) by radish.cambridge.redhat.com (8.12.10/8.12.7) with ESMTP id i7RCPoHP029592 for ; Fri, 27 Aug 2004 13:25:50 +0100 Received: (from jorton@localhost) by radish.cambridge.redhat.com (8.12.10/8.12.10/Submit) id i7RCPoaf029591 for internals@lists.php.net; Fri, 27 Aug 2004 13:25:50 +0100 Date: Fri, 27 Aug 2004 13:25:50 +0100 To: internals@lists.php.net Message-ID: <20040827122550.GC29943@redhat.com> Mail-Followup-To: internals@lists.php.net Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.4.1i Subject: [PATCH] zend_operators DVAL_TO_LVAL fix From: jorton@redhat.com (Joe Orton) 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): 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) { \