repo.or.cz
/
hiphop-php.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
optional integer overflow logging/exception (#8585)
[hiphop-php.git]
/
hphp
/
test
/
slow
/
int_overflow
/
mul_1.php
blob
72080b15806f9b0f5e017778f901e68951078d1c
1
<
?hh
2
3
<<
__EntryPoint
>>
function
main
():
void
{
4
$mul
=
function
(
$a
,
$b
) {
5
try
{
6
$c
=
$a
*
$b
;
7
printf
(
"
%s
*
%s
=
%s\n
"
,
8
var_export
(
$a
,
true
),
9
var_export
(
$b
,
true
),
10
var_export
(
$c
,
true
));
11
}
catch
(
ArithmeticError
$ex
) {
12
printf
(
"exception for
%s
*
%s
:
%s\n
"
,
13
var_export
(
$a
,
true
),
14
var_export
(
$b
,
true
),
15
$ex
->
getMessage
());
16
return
-
1
;
17
}
18
};
19
20
$max
=
PHP_INT_MAX
;
21
$min
=
1
<<
63
;
22
23
$mul
(
$max
,
2
);
24
$mul
(
$max
, -
2
);
25
$mul
(
"
$max
"
,
2
);
26
$mul
(
$max
,
'2'
);
27
$mul
(
"
$max
"
,
'2'
);
28
29
$mul
(
$min
, -
2
);
30
$mul
(
$min
,
2
);
31
$mul
(
"
$min
"
, -
2
);
32
$mul
(
$min
,
'-2'
);
33
$mul
(
"
$min
"
,
'-2'
);
34
}