Fixing OpMod emission not to trigger assert in simplifier
If you tried to mod something where the denominator was cns(0), things would go horribly, horribly wrong.
Esse commit está contido em:
@@ -3229,6 +3229,12 @@ void HhbcTranslator::emitMod() {
|
||||
// of the branches gets optimized out due to constant folding.
|
||||
if (tr->getValInt() == -1LL) {
|
||||
push(cns(0));
|
||||
} else if (tr->getValInt() == 0) {
|
||||
// mod by zero is undefined. don't emit opmod for it because
|
||||
// this could cause issues in simplifier/codegen
|
||||
// this should never get reached anyway, we just need to dump
|
||||
// something on the stack
|
||||
push(cns(false));
|
||||
} else {
|
||||
push(gen(OpMod, tl, tr));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
function one() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function main() {
|
||||
var_dump(one() % 0);
|
||||
}
|
||||
main();
|
||||
@@ -0,0 +1,2 @@
|
||||
HipHop Warning: Division by zero in %s on line 8
|
||||
bool(false)
|
||||
Referência em uma Nova Issue
Bloquear um usuário