-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* PHP-8.4: ext/gmp: Fix segfault when null is encountered on an overloaded operator ext/gmp: Add behavioural tests for operator overloading
- Loading branch information
Showing
12 changed files
with
1,093 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--TEST-- | ||
GMP comparison operator overloading supports null | ||
--EXTENSIONS-- | ||
gmp | ||
--FILE-- | ||
<?php | ||
|
||
$num = gmp_init(42); | ||
|
||
try { | ||
var_dump($num < null); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num > null); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num <= null); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num >= null); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num == null); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num <=> null); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
?> | ||
--EXPECT-- | ||
bool(false) | ||
bool(true) | ||
bool(false) | ||
bool(true) | ||
bool(false) | ||
int(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--TEST-- | ||
GMP operator overloading does not support [] | ||
--EXTENSIONS-- | ||
gmp | ||
--FILE-- | ||
<?php | ||
|
||
$num = gmp_init(42); | ||
|
||
try { | ||
var_dump($num + []); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num - []); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num * []); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num / []); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num % []); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num ** []); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num | []); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
try { | ||
var_dump($num & []); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
try { | ||
var_dump($num ^ []); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
try { | ||
var_dump($num << []); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
try { | ||
var_dump($num >> []); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
?> | ||
--EXPECT-- | ||
TypeError: Number must be of type GMP|string|int, array given | ||
TypeError: Number must be of type GMP|string|int, array given | ||
TypeError: Number must be of type GMP|string|int, array given | ||
TypeError: Number must be of type GMP|string|int, array given | ||
TypeError: Number must be of type GMP|string|int, array given | ||
TypeError: Unsupported operand types: GMP ** array | ||
TypeError: Number must be of type GMP|string|int, array given | ||
TypeError: Number must be of type GMP|string|int, array given | ||
TypeError: Number must be of type GMP|string|int, array given | ||
TypeError: Unsupported operand types: GMP << array | ||
TypeError: Unsupported operand types: GMP >> array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
--TEST-- | ||
GMP operator overloading does support float with no fractional | ||
--EXTENSIONS-- | ||
gmp | ||
--FILE-- | ||
<?php | ||
|
||
$num = gmp_init(42); | ||
|
||
try { | ||
var_dump($num + 42.0); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num - 42.0); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num * 42.0); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num / 42.0); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num % 42.0); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num ** 42.0); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
var_dump($num | 42.0); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
try { | ||
var_dump($num & 42.0); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
try { | ||
var_dump($num ^ 42.0); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
try { | ||
var_dump($num << 42.0); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
try { | ||
var_dump($num >> 42.0); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
?> | ||
--EXPECT-- | ||
object(GMP)#2 (1) { | ||
["num"]=> | ||
string(2) "84" | ||
} | ||
object(GMP)#2 (1) { | ||
["num"]=> | ||
string(1) "0" | ||
} | ||
object(GMP)#2 (1) { | ||
["num"]=> | ||
string(4) "1764" | ||
} | ||
object(GMP)#2 (1) { | ||
["num"]=> | ||
string(1) "1" | ||
} | ||
object(GMP)#2 (1) { | ||
["num"]=> | ||
string(1) "0" | ||
} | ||
object(GMP)#2 (1) { | ||
["num"]=> | ||
string(69) "150130937545296572356771972164254457814047970568738777235893533016064" | ||
} | ||
object(GMP)#2 (1) { | ||
["num"]=> | ||
string(2) "42" | ||
} | ||
object(GMP)#2 (1) { | ||
["num"]=> | ||
string(2) "42" | ||
} | ||
object(GMP)#2 (1) { | ||
["num"]=> | ||
string(1) "0" | ||
} | ||
object(GMP)#2 (1) { | ||
["num"]=> | ||
string(15) "184717953466368" | ||
} | ||
object(GMP)#2 (1) { | ||
["num"]=> | ||
string(1) "0" | ||
} |
Oops, something went wrong.