Bug #71090 [Opn]: Comparison operators loop

From: Date: Fri, 11 Dec 2015 13:37:02 +0000
Subject: Bug #71090 [Opn]: Comparison operators loop
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197790@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71090&edit=1 ID: 71090 Updated by: laruence@php.net Reported by: reallfqq-php at yahoo dot fr Summary: Comparison operators loop Status: Open Type: Bug Package: Scripting Engine problem PHP Version: 7.0.0 Block user comment: N Private report: N New Comment: the problem is INF, comparing sequence matters here. Previous Comments: ------------------------------------------------------------------------ [2015-12-11 12:19:10] reallfqq-php at yahoo dot fr Description: ------------ PHP's comparison operators are circular, generatng situations where impossible equalities are considered valid. This bug is posted in reference to: http://phpsadness.com/sad/52 Test script: --------------- <?php function is_sorted($array) { $n = count($array); for ($a=0; $a<$n-1; $a++) { for ($b=$a+1; $b<$n; $b++) { if ($array[$a] > $array[$b]) { return false; } } } return true; } $array = array(INF, array(), (object)array()); sort($array); var_dump(is_sorted($array)) ?> Expected result: ---------------- bool(true) Actual result: -------------- bool(false) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71090&edit=1

« previous php.bugs (#197790) next »