Bug #75192 [Opn->Ana]: Spaceship operator returns wrong value for GMP numbers
| From: | requinix@php.net | Date: | Tue, 12 Sep 2017 05:19:18 +0000 |
| Subject: | Bug #75192 [Opn->Ana]: Spaceship operator returns wrong value for GMP numbers | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211083@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75192&edit=1
ID: 75192
Updated by: requinix@php.net
Reported by: marcospassos dot com at gmail dot com
Summary: Spaceship operator returns wrong value for GMP
numbers
-Status: Open
+Status: Analyzed
Type: Bug
Package: GNU MP related
Operating System: Mac
PHP Version: 7.1.9
Block user comment: N
Private report: N
New Comment:
gmp's <=> overload wraps gmp_cmp() so it should be a pretty simple fix to
gmp.c:gmp_compare to bound the return to -1/+1.
Though personally I wish <=> wasn't so rigid to begin with.
Previous Comments:
------------------------------------------------------------------------
[2017-09-12 01:38:42] marcospassos dot com at gmail dot com
In fact, the operator overloading works, but the result is not compatible with the operator
specification.
------------------------------------------------------------------------
[2017-09-12 01:34:56] marcospassos dot com at gmail dot com
Description:
------------
Operator overloading does not work for the spaceship operator.
Test script:
---------------
$result = gmp_init('1') <=> gmp_init('-1');
Expected result:
----------------
1
Actual result:
--------------
2
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75192&edit=1