1--TEST--
2Temporary leak with foreach
3--FILE--
4<?php
5
6function ops() {
7    throw new Exception();
8}
9
10$a = [new stdClass, new stdClass];
11foreach ([$a, [new stdClass]] as $b) {
12    switch ($b[0]) {
13        case false:
14        break;
15        default:
16            try {
17                $x = 2;
18                $y = new stdClass;
19                while ($x-- && new stdClass) {
20                    $r = [$x] + ($y ? ((array) $x) + [2] : ops());
21                    $y = (array) $y;
22                }
23            } catch (Exception $e) {
24            }
25    }
26}
27
28foreach ([$a, [new stdClass]] as $b) {
29    try {
30        switch ($b[0]) {
31            case false:
32            break;
33            default:
34                $x = 2;
35                $y = new stdClass;
36                while ($x-- && new stdClass) {
37                    $r = [$x] + ($y ? ((array) $x) + [2] : ops());
38                    $y = (array) $y;
39                }
40        }
41    } catch (Exception $e) {
42    }
43}
44
45?>
46==DONE==
47--EXPECT--
48==DONE==
49