Bug #75445 [NEW]: User-defined assert function is optimized away with zend.assertions=-1
| From: | kelunik@php.net | Date: | Fri, 27 Oct 2017 08:48:43 +0000 |
| Subject: | Bug #75445 [NEW]: User-defined assert function is optimized away with zend.assertions=-1 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-212334@lists.php.net to get a copy of this message | ||
From: kelunik
Operating system: Irrelevant
PHP version: 7.2.0RC5
Package: Scripting Engine problem
Bug Type: Bug
Bug description:User-defined assert function is optimized away with zend.assertions=-1
Description:
------------
Execute the test script:
- php -d zend.assertions=1 test.php
- php -d zend.assertions=0 test.php
- php -d zend.assertions=-1 test.php
assert() doesn't respect the namespace fallback, but assumes
unqualified calls are equivalent to \assert() and optimize it away /
jump around it with assertions disabled.
This is unfortunate, as few people use \assert() over assert() and
wouldn't gain zero-cost assertions without this behavior.
Test script:
---------------
<?php
namespace Test {
function assert() {
global $foo;
$foo = true;
}
}
namespace Test {
assert();
var_dump(isset($foo));
}
Expected result:
----------------
bool(true)
Actual result:
--------------
bool(false)
--
Edit bug report at https://bugs.php.net/bug.php?id=75445&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75445&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75445&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75445&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75445&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75445&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75445&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75445&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75445&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75445&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75445&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75445&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75445&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75445&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75445&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75445&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75445&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75445&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75445&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75445&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75445&r=mysqlcfg