1--TEST--
2Empty foreach loops with exception must not leak
3--FILE--
4<?php
5
6class Foo implements IteratorAggregate {
7    public function getIterator() {
8        return new ArrayIterator([]);
9    }
10    public function __destruct() {
11        throw new Exception;
12    }
13}
14
15try {
16    foreach (new Foo as $x);
17} catch (Exception $e) {
18    echo "Exception caught\n";
19}
20
21?>
22--EXPECT--
23Exception caught
24