Bug #69906 [Asn]: chr() behavior difference between 32- and 64-bit bulids

From: Date: Tue, 23 Jun 2015 20:15:04 +0000
Subject: Bug #69906 [Asn]: chr() behavior difference between 32- and 64-bit bulids
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193816@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69906&edit=1 ID: 69906 Updated by: bwoebi@php.net Reported by: ab@php.net Summary: chr() behavior difference between 32- and 64-bit bulids Status: Assigned Type: Bug Package: *General Issues Operating System: any PHP Version: 7.0.0alpha1 Assigned To: ab Block user comment: N Private report: N New Comment: May I request to not have that changed? That's technically a BC break, because there's code out there relying on chr() implicitly doing & 0xFF on the passed param. I think that's rather a doc bug? Previous Comments: ------------------------------------------------------------------------ [2015-06-23 07:22:19] ab@php.net Description: ------------ When passing an integer that overflows PHP_INT_MAX in 32-bit, the behavior of chr() differs. The documentation currently doesn't define what should happen in this situation, the only statement is that chr() expects an ASCII code. chr() should ensure the input is in the valid range, thus making the behavior consistent between 32- and 64-bit. Test script: --------------- Debug\php.exe -r "$a = chr(2632627629); var_dump($a, ord($a));" string(1) " " int(0) x64\Debug\php.exe -r "$a = chr(2632627629); var_dump($a, ord($a));" string(1) "¡" int(173) Expected result: ---------------- string(1) " " int(0) Actual result: -------------- Different behavior depending on 32- or 64-bit build. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69906&edit=1

« previous php.bugs (#193816) next »