xref: /PHP-8.1/Zend/tests/bug71300.phpt (revision f8d79582)
1--TEST--
2Bug #71300 (Segfault in zend_fetch_string_offset)
3--FILE--
4<?php
5function test1() {
6    for ($n = 'a'; $n < 'g'; $n++) {
7        $$n = 1;
8    }
9    $$n = $$n[++$n] = "test";
10    return $$n;
11}
12
13var_dump(test1());
14
15function test2() {
16    /* See #71303 for why not using for loop here */
17    $n = "a";
18    $$n .= $$n[++$n] = "test";
19    return $$n;
20}
21
22var_dump(test2());
23?>
24--EXPECTF--
25string(4) "test"
26
27Warning: Array to string conversion in %s on line %d
28string(9) "Arraytest"
29