Edit report at https://bugs.php.net/bug.php?id=80630&edit=1

 ID:                 80630
 Comment by:         ravi_salamani at gmail dot com
 Reported by:        ravi_salamani at gmail dot com
 Summary:            Zend/tests/runtime_compile_time_binary_operands.phpt
                     failed
 Status:             Feedback
 Type:               Feature/Change Request
 Package:            Testing related
 Operating System:   RHEL 7.x/8.x
 PHP Version:        8.0.1
 Block user comment: N
 Private report:     N

 New Comment:

I am still facing issue for s390x for  RHEL distributions (RHEL 
7.8/7.9/8.1/8.2/8.3)


Previous Comments:
------------------------------------------------------------------------
[2021-01-26 18:20:17] simrit dot kaur at ibm dot com

I am facing this as well on RHEL Distros.
I have tested on RHEL 7.8, 7.9, 8.1, 8.2 and 8.3 with s390x arch.
PHP release version: 8.0.1

------------------------------------------------------------------------
[2021-01-19 15:09:27] ni...@php.net

On which CPU architecture is this?

I do know this test works on s390x, which is bid endian as well.

------------------------------------------------------------------------
[2021-01-15 12:49:50] ravi_salamani at gmail dot com

Description:
------------
PHP Version: v8.0.1
Failure is observed on big-endian system on rhel distributions.

php:
<?php

$binaryOperators = [
    "==",
    "!=",
    "===",
    "!==",
    "<",
    "<=",
    ">",
    ">=",
    "<=>",
    "+",
    "-",
    "*",
    "/",
    "%",
    "**",
    ".",
    "|",
    "&",
    "^",
    "or",
    "and",
    "xor",
    "||",
    "&&",
];
$unaryOperators = [
    "~",
    "-",
    "+",
    "!",
];

$input = [
    0,
    1,
    2,
    -1,
    2.0,
    2.1,
    -2.0,
    -2.1,
    PHP_INT_MAX,
    PHP_INT_MIN,
    PHP_INT_MAX * 2,
    PHP_INT_MIN * 2,
    INF,
    NAN,
    [],
    [1, 2],
    [1, 2, 3],
    [1 => 2, 0 => 1],
    [1, 'a' => 2],
    [1, 4],
    [1, 'a'],
    [1, 2 => 2],
    [1, [ 2 ]],
    null,
    false,
    true,
    "",
    " ",
    "banana",
    "Banana",
    "banan",
    "0",
    "200",
    "20",
    "20a",
    " \t\n\r\v\f20",
    "20  ",
    "2e1",
    "2e150",
    
"9179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368",
    
"-9179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368",
    "0.1",
    "-0.1",
    "1e-1",
    "-20",
    "-20.0",
    "0x14",
    (string) PHP_INT_MAX * 2,
    (string) PHP_INT_MIN * 2,
];

function makeParam($param) {
    if ($param === PHP_INT_MIN) {
        return "PHP_INT_MIN";
    }
    if ($param === PHP_INT_MAX) {
        return "PHP_INT_MAX";
    }
    if (is_string($param)) {
        return '"' . strtr($param, ["\t" => '\t', "\n" => '\n', "\r" => '\r', 
"\v" => '\v', "\f" => '\f', '$' => '\$', '"' => '\"']) . '"';
    }
    return "(" . str_replace("\n", "", var_export($param, true)) . ")";
}

$c = 0;
$f = 0;

function prepareBinaryLine($op1, $op2, $cmp, $operator) {
    $op1_p = makeParam($op1);
    $op2_p = makeParam($op2);

    $error = "echo '" . addcslashes("$op1_p $operator $op2_p", "\\'") . '\', 
"\n"; $f++;';

    $compare = "@($op1_p $operator $op2_p)";
    $line = "\$c++; ";
    try {
        $result = makeParam($cmp());
        $line .= "if (" . ($result === "(NAN)" ? "!is_nan($compare)" : 
"$compare !== $result") . ") { $error }";
    } catch (Error $e) {
        $msg = makeParam($e->getMessage());
        $line .= "try { $compare; $error } catch (Error \$e) { if 
(\$e->getMessage() !== $msg) { $error } }";
    }
    return $line;
}
function prepareUnaryLine($op, $cmp, $operator) {
    $op_p = makeParam($op);

    $error = "echo '" . addcslashes("$operator $op_p", "\\'") . '\', "\n"; 
$f++;';

    $compare = "@($operator $op_p)";
    $line = "\$c++; ";
    try {
        $result = makeParam($cmp());
        $line .= "if (" . ($result === "(NAN)" ? "!is_nan($compare)" : 
"$compare !== $result") . ") { $error }";
    } catch (Error $e) {
        $msg = makeParam($e->getMessage());
        $line .= "try { $compare; $error } catch (Error \$e) { if 
(\$e->getMessage() !== $msg) { $error } }";
    }
    return $line;
}

$filename = __DIR__ . DIRECTORY_SEPARATOR . 'compare_binary_operands_temp.php';
$file = fopen($filename, "w");

fwrite($file, "<?php\n");

foreach ($input as $left) {
    foreach ($input as $right) {
        foreach ($binaryOperators as $operator) {
            $line = prepareBinaryLine($left, $right, function() use ($left, 
$right, $operator) {
                return eval("return @(\$left $operator \$right);");
            }, $operator);
            fwrite($file, $line . "\n");
        }
    }
}
foreach ($input as $right) {
    foreach ($unaryOperators as $operator) {
        $line = prepareUnaryLine($right, function() use ($right, $operator) {
            return eval("return @($operator \$right);");
        }, $operator);
        fwrite($file, $line . "\n");
    }
}

fclose($file);

include $filename;

if($c === 0) {
    echo "Completely failed\n";
} else {
    echo "Failed: $f\n";
}
?>


Expected result:
----------------
Failed: 0

Actual result:
--------------
(0) < (NAN)
(0) <= (NAN)
(0) > (NAN)
(0) >= (NAN)
(1) < (NAN)
(1) <= (NAN)
(1) > (NAN)
(1) >= (NAN)
(2) < (NAN)
(2) <= (NAN)
(2) > (NAN)
(2) >= (NAN)
(-1) < (NAN)
(-1) <= (NAN)
(-1) > (NAN)
(-1) >= (NAN)
(2.0) < (NAN)
(2.0) <= (NAN)
(2.0) > (NAN)
(2.0) >= (NAN)
(2.1) < (NAN)
(2.1) <= (NAN)
(2.1) > (NAN)
(2.1) >= (NAN)
(-2.0) < (NAN)
(-2.0) <= (NAN)
(-2.0) > (NAN)
(-2.0) >= (NAN)
(-2.1) < (NAN)
(-2.1) <= (NAN)
(-2.1) > (NAN)
(-2.1) >= (NAN)
PHP_INT_MAX < (NAN)
PHP_INT_MAX <= (NAN)
PHP_INT_MAX > (NAN)
PHP_INT_MAX >= (NAN)
PHP_INT_MIN < (NAN)
PHP_INT_MIN <= (NAN)
PHP_INT_MIN > (NAN)
PHP_INT_MIN >= (NAN)
(1.8446744073709552E+19) < (NAN)
(1.8446744073709552E+19) <= (NAN)
(1.8446744073709552E+19) > (NAN)
(1.8446744073709552E+19) >= (NAN)
(-1.8446744073709552E+19) < (NAN)
(-1.8446744073709552E+19) <= (NAN)
(-1.8446744073709552E+19) > (NAN)
(-1.8446744073709552E+19) >= (NAN)
(INF) < (NAN)
(INF) <= (NAN)
(INF) > (NAN)
(INF) >= (NAN)
(NAN) < (0)
(NAN) <= (0)
(NAN) > (0)
(NAN) >= (0)
(NAN) < (1)
(NAN) <= (1)
(NAN) > (1)
(NAN) >= (1)
(NAN) < (2)
(NAN) <= (2)
(NAN) > (2)
(NAN) >= (2)
(NAN) < (-1)
(NAN) <= (-1)
(NAN) > (-1)
(NAN) >= (-1)
(NAN) < (2.0)
(NAN) <= (2.0)
(NAN) > (2.0)
(NAN) >= (2.0)
(NAN) < (2.1)
(NAN) <= (2.1)
(NAN) > (2.1)
(NAN) >= (2.1)
(NAN) < (-2.0)
(NAN) <= (-2.0)
(NAN) > (-2.0)
(NAN) >= (-2.0)
(NAN) < (-2.1)
(NAN) <= (-2.1)
(NAN) > (-2.1)
(NAN) >= (-2.1)
(NAN) < PHP_INT_MAX
(NAN) <= PHP_INT_MAX
(NAN) > PHP_INT_MAX
(NAN) >= PHP_INT_MAX
(NAN) < PHP_INT_MIN
(NAN) <= PHP_INT_MIN
(NAN) > PHP_INT_MIN
(NAN) >= PHP_INT_MIN
(NAN) < (1.8446744073709552E+19)
(NAN) <= (1.8446744073709552E+19)
(NAN) > (1.8446744073709552E+19)
(NAN) >= (1.8446744073709552E+19)
(NAN) < (-1.8446744073709552E+19)
(NAN) <= (-1.8446744073709552E+19)
(NAN) > (-1.8446744073709552E+19)
(NAN) >= (-1.8446744073709552E+19)
(NAN) < (INF)
(NAN) <= (INF)
(NAN) > (INF)
(NAN) >= (INF)
(NAN) < (NAN)
(NAN) <= (NAN)
(NAN) > (NAN)
(NAN) >= (NAN)
(NAN) < (1.8446744073709552E+19)
(NAN) <= (1.8446744073709552E+19)
(NAN) > (1.8446744073709552E+19)
(NAN) >= (1.8446744073709552E+19)
(NAN) < (-1.8446744073709552E+19)
(NAN) <= (-1.8446744073709552E+19)
(NAN) > (-1.8446744073709552E+19)
(NAN) >= (-1.8446744073709552E+19)
(1.8446744073709552E+19) < (NAN)
(1.8446744073709552E+19) <= (NAN)
(1.8446744073709552E+19) > (NAN)
(1.8446744073709552E+19) >= (NAN)
(-1.8446744073709552E+19) < (NAN)
(-1.8446744073709552E+19) <= (NAN)
(-1.8446744073709552E+19) > (NAN)
(-1.8446744073709552E+19) >= (NAN)
Failed: 124


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80630&edit=1

Reply via email to