Bug #18526: assertion fails

From: Date: Wed, 24 Jul 2002 06:58:20 +0000
Subject: Bug #18526: assertion fails
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-14986@lists.php.net to get a copy of this message
From: horny@mail.az Operating system: Windows XP PHP version: 4.2.1 PHP Bug Type: Unknown/Other Function Bug description: assertion fails <?php assert_options(ASSERT_ACTIVE, '1'); assert_options(ASSERT_WARNING, '1'); assert_options(ASSERT_QUIET_EVAL, '0'); $AVAILABLE_LANGS = array('az' => 'az', 'ru' => 'ru', 'en' => 'en'); # as per RFC 1766 function func($predicate) { do { $freeflag = null; if (call_user_func($predicate, $freeflag) === FALSE) break; assert('!is_null($freeflag)'); } while (0); } class foo { function foo_method(&$freeflag) { $retval = (bool) rand() % 2; if ($retval) $freeflag = 1; return $retval; } } $foo_instance = new foo; func(array($foo_instance, 'foo_method')); ?> D:\>c:\php\php-cli haha.php Warning: Assertion "!is_null($freeflag)" failed in haha.php on line 14 It occurs *always* no matter what foo_method() returns, as if asserts() are happening asynchronously. If I instead change func() to function func($predicate) { $freeflag = null; if (call_user_func($predicate, $freeflag) === TRUE) assert('!is_null($freeflag)'); } The assertion doesn't fail. (because it's NOTREACHED?) -- Edit bug report at http://bugs.php.net/?id=18526&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=18526&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=18526&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=18526&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=18526&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=18526&r=support Expected behavior: http://bugs.php.net/fix.php?id=18526&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=18526&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=18526&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=18526&r=globals

« previous php.bugs (#14986) next »