#18526 [Com]: assertion fails
| From: | horny at mail dot az | Date: | Tue, 30 Jul 2002 05:16:16 +0000 |
| Subject: | #18526 [Com]: assertion fails | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-15542@lists.php.net to get a copy of this message | ||
ID: 18526
Comment by: horny@mail.az
Reported By: horny@mail.az
Status: Open
Bug Type: Unknown/Other Function
Operating System: Windows XP
PHP Version: 4.2.1
New Comment:
This is my bug.
$retval = (bool) rand() % 2;
should of course be
$retval = (bool) (rand() % 2);
But in the real code (off of which I made up this example) the
assertion still fails mysteriously...
Previous Comments:
------------------------------------------------------------------------
[2002-07-24 02:58:19] horny@mail.az
<?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 this bug report at http://bugs.php.net/?id=18526&edit=1