Bug #71948 [NEW]: Variables by reference broken as of 7.0.5

From: Date: Sat, 02 Apr 2016 13:32:06 +0000
Subject: Bug #71948 [NEW]: Variables by reference broken as of 7.0.5
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200304@lists.php.net to get a copy of this message
From:             dane dot tschi at gmail dot com
Operating system: Unix/OSX
PHP version:      7.0.5
Package:          Variables related
Bug Type:         Bug
Bug description:Variables by reference broken as of 7.0.5

Description:
------------
We tried upgrading from php 7.0.4 to 7.0.5. Unfortunately zendframework
stopped working. After debugging I came up with a reduced testcase that
reproduces the issue.

On php 7.0.4 it outputs the expected result, on 7.0.5 the wrong result.


This only happens if the switch-case is in there, if i replace it with
if/else it works.



Test script:
---------------
<?php
$tokenIndex = 0;
$tokens = [T_WHITESPACE, T_CLASS];
$tokenType = null;

$MACRO_TOKEN_ADVANCE = function () use (&$tokenType, &$tokenIndex,
$tokens) {
  if (!isset($tokens[$tokenIndex])) return false;
  $tokenType = $tokens[$tokenIndex++];

  return $tokenType;
};
$MACRO_TOKEN_ADVANCE();

SCANNER_TOP:
switch($tokenType) {
  case T_WHITESPACE: echo "whitespace"; break;
  case T_CLASS: echo "class"; break;
}

if ($MACRO_TOKEN_ADVANCE() !== false) goto SCANNER_TOP;

Expected result:
----------------
whitespaceclass

Actual result:
--------------
whitespacewhitespace

-- 
Edit bug report at https://bugs.php.net/bug.php?id=71948&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=71948&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=71948&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=71948&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=71948&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=71948&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=71948&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=71948&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=71948&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=71948&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=71948&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=71948&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=71948&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=71948&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71948&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=71948&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=71948&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=71948&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71948&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=71948&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=71948&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#200304) next »