php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch 0001-Fixed-bug-64142-dval-to-lval-different-behavior-on-p.patch for *General Issues Bug #64142

Patch version 2013-02-04 14:30 UTC

Return to Bug #64142 | Download this patch
Patch Revisions:

Developer: remi@php.net

From 6533094d9e4d0c85044a170d9fad9a3986a68675 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@php.net>
Date: Mon, 4 Feb 2013 15:19:32 +0100
Subject: [PATCH] Fixed bug #64142 (dval to lval different behavior on ppc64)

On x86_64:
(long)(double)9223372036854775807+1 = -9223372036854775808
On ppc64
(long)(double)9223372036854775807-1 = 9223372036854775807
---
 NEWS                  | 3 +++
 Zend/zend_operators.h | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 2aff180..0649d9d 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,9 @@ PHP                                                                        NEWS
 - CLI server:
   . Fixed bug #64128 (buit-in web server is broken on ppc64). (Remi)
 
+- Core:
+  . Fixed bug #64142 (dval to lval different behavior on ppc64). (Remi)
+
 ?? ??? 2012, PHP 5.4.12
 
 - Core:
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index 02a96dd..93b904f 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -79,7 +79,7 @@ static zend_always_inline long zend_dval_to_lval(double d)
 #else
 static zend_always_inline long zend_dval_to_lval(double d)
 {
-	if (d > LONG_MAX) {
+	if (d >= LONG_MAX) {
 		return (long)(unsigned long) d;
 	}
 	return (long) d;
-- 
1.7.11.7

 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 21:01:56 2014 UTC