#32315 [NEW]: Destructor is called although Constructor throws an exception

From: Date: Tue, 15 Mar 2005 14:40:19 +0000
Subject: #32315 [NEW]: Destructor is called although Constructor throws an exception
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-75373@lists.php.net to get a copy of this message
From: m dot wiegard at brandsetter dot de Operating system: MacOs x (10.3.7) PHP version: 5.0.3 PHP Bug Type: Class/Object related Bug description: Destructor is called although Constructor throws an exception Description: ------------ The bug appears if I'm using any method calls with & (and only with &, I read the other bug reports !!!!!!) to assign the result to a variable within the constructor. if an Exception is thrown after that within the constructor, the destructor is called, although no object was instantiated. Reproduce code: --------------- <?php class test1 { private $test; function __construct() { $this->test =& test1::staticMethod(); throw new Exception(); } static function staticMethod() { return true; } function __destruct() { print 'DESTRUCTOR'; } } $test = new test1(); ?> Expected result: ---------------- I Expected to see no output of my little listing itself, only the error messages. Actual result: -------------- After the exception was printed out in the output, DESTRUCTOR appeared. -- Edit bug report at http://bugs.php.net/?id=32315&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32315&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32315&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32315&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=32315&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=32315&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=32315&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=32315&r=needscript Try newer version: http://bugs.php.net/fix.php?id=32315&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=32315&r=support Expected behavior: http://bugs.php.net/fix.php?id=32315&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=32315&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=32315&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=32315&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32315&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=32315&r=dst IIS Stability: http://bugs.php.net/fix.php?id=32315&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=32315&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=32315&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=32315&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=32315&r=mysqlcfg

« previous php.bugs (#75373) next »