Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32733 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46085 invoked by uid 1010); 11 Oct 2007 08:46:00 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 46070 invoked from network); 11 Oct 2007 08:46:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Oct 2007 08:46:00 -0000 Authentication-Results: pb1.pair.com header.from=maurice@iceblog.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=maurice@iceblog.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain iceblog.de from 217.160.111.22 cause and error) X-PHP-List-Original-Sender: maurice@iceblog.de X-Host-Fingerprint: 217.160.111.22 p15097164.pureserver.info Received: from [217.160.111.22] ([217.160.111.22:59959] helo=p15097164.pureserver.info) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/96-28218-5C2ED074 for ; Thu, 11 Oct 2007 04:45:59 -0400 Received: (qmail 11462 invoked by uid 89); 11 Oct 2007 08:45:55 -0000 Received: from pd95b159d.dip0.t-ipconnect.de (HELO ?192.168.2.9?) (moritz@mertinkat.net@217.91.21.157) by p15097164.pureserver.info with SMTP; 11 Oct 2007 08:45:55 -0000 Message-ID: <470DE2BF.1090907@iceblog.de> Date: Thu, 11 Oct 2007 10:45:51 +0200 User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Strange integer overflows From: maurice@iceblog.de (Maurice) Hi there, I stumbled upon a very strange behaviour with integer overflows. On 64-bit systems running a 64-bit operating system (with a PHP compiled for that operating system) it seems that PHP uses 64-bit integers instead of 32-bit integer (which is the expected behaviour afaik). On 32-bit system PHP should use 32-bit integer. Thus, the number -17441010873 (> 32 bit) should be "overflowed" to -261141689 (32-bit). However on all 32-bit Linux system using PHP5 (int)-17441010873 is mapped to -2147483648 (INT_MIN). On some systems the result in PHP4 is also screwed up. On Windows XP Pro (32-bit) both PHP5 and PHP4 are working correctly. Try running the following snippet with PHP4 and PHP5 on your (32-bit) system. For me it looks like a damn bug... is it a bug? Or a "feature"? Bye, Maurice