|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39017 foreach(($obj = new myClass) as $v); echo $obj; segfaults
Submitted: 2006-10-02 16:26 UTC Modified: 2006-10-03 09:12 UTC
From: Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.1.6 OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
New email:
PHP Version: OS:


 [2006-10-02 16:26 UTC]
The foreach construct destroys the object, leaving the variable in a strange state.

class A {} foreach(($a = new A) as $v);
var_dump($a); // UNKNOWN:0
echo $a; // segfaults

This was spotted by Zuu on ##php@freenode.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-03 09:12 UTC]
Fixed in CVS HEAD and  PHP_5_2.
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Sep 22 03:01:26 2019 UTC