BOOL (next to QM_ASSIGN) is one of the opcodes that can assign to
a temporary that is assigned in multiple branches. Pass 1 does
not check for this, so we should not try to handle it at that
point. Block pass and sccp will be able to treat this correctly.
case ZEND_BW_NOT:
case ZEND_BOOL_NOT:
- case ZEND_BOOL:
if (opline->op1_type == IS_CONST) {
/* unary operation on constant operand */
zval result;
--- /dev/null
+--TEST--
+Incorrect constant propagation on BOOL in pass 1
+--FILE--
+<?php
+function test($foo) {
+ $bar = 0;
+ if ($bar === 1 && $foo && PHP_SAPI !== 'cgi') {
+ echo "bar\n";
+ }
+ echo "foo\n";
+}
+test(1);
+?>
+--EXPECT--
+foo