]> granicus.if.org Git - php/commitdiff
Disable negative range inference
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 18 Feb 2018 14:13:14 +0000 (15:13 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Sun, 18 Feb 2018 14:33:28 +0000 (15:33 +0100)
The negative range inference implementation does not work correctly,
and it's not clear right now how it can be fixed. As such, disable
it entirely for now.

ext/opcache/Optimizer/zend_inference.c
ext/opcache/tests/neg_range_inference.phpt [new file with mode: 0644]

index 1bfd395dd0853df08974c29d51164e073483e263..b5488c4dc00dbd0e587e328ea6ce2e7f44b1a849 100644 (file)
@@ -39,7 +39,8 @@
 #define SYM_RANGE
 
 /* Whether to handle negative range constraints */
-#define NEG_RANGE
+/* Negative range inference is buggy, so disabled for now */
+#undef NEG_RANGE
 
 /* Number of warmup passes to use prior to widening */
 #define RANGE_WARMUP_PASSES 16
diff --git a/ext/opcache/tests/neg_range_inference.phpt b/ext/opcache/tests/neg_range_inference.phpt
new file mode 100644 (file)
index 0000000..b3dd4a7
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+Incorrect negative range inference
+--FILE--
+<?php
+
+function test() {
+    for ($i = 0; $i < 10; $i++) {
+        if ($i != 5) {
+            $t = (int) ($i < 5);
+            var_dump($t);
+        }
+    }
+}
+test();
+
+?>
+--EXPECT--
+int(1)
+int(1)
+int(1)
+int(1)
+int(1)
+int(0)
+int(0)
+int(0)
+int(0)