|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81379 gmp_init() not accepting GMP values despite saying so
Submitted: 2021-08-24 11:37 UTC Modified: 2021-08-24 13:12 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: michelbach94 at gmail dot com Assigned:
Status: Verified Package: GNU MP related
PHP Version: 8.0.9 OS: Manjaro
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: michelbach94 at gmail dot com
New email:
PHP Version: OS:


 [2021-08-24 11:37 UTC] michelbach94 at gmail dot com
gmp_init() is documented to only accept strings and ints. However, its error message says that it also accepts GMP objects while simultaneously saying it does not.

Test script:
php > gmp_init(gmp_init(5));
PHP Warning:  Uncaught TypeError: gmp_init(): Argument #1 ($num) must be of type GMP|string|int, GMP given in php shell code:1
Stack trace:
#0 php shell code(1): gmp_init(Object(GMP))
#1 {main}
  thrown in php shell code on line 1


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-24 12:10 UTC]
-Status: Open +Status: Verified
 [2021-08-24 12:10 UTC]
Indeed.  The problem is that convert_to_gmp() is used to convert
the arguments of several GMP functions, and all of them but
gmp_init() actually accept GMP instances.  Maybe just accept GMP
instances for gmp_init() as well?
 [2021-08-24 13:12 UTC]
I'm okay with accepting GMP in gmp_init().
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Aug 13 21:05:45 2022 UTC