php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65580 reference will affect expression result with multiple ++$x
Submitted: 2013-08-29 02:58 UTC Modified: 2013-08-30 20:51 UTC
From: xiezhenye at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.5.3 OS: Any
Private report: No CVE-ID: None
 [2013-08-29 02:58 UTC] xiezhenye at gmail dot com
Description:
------------
reference will affect expression result with multiple ++$x.


Test script:
---------------
$a = 1;
echo (++$a)+(++$a);


$a = 1;
$b = &$a;
echo (++$a)+(++$a);



Expected result:
----------------
55

Actual result:
--------------
56

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-30 20:51 UTC] aharvey@php.net
-Status: Open +Status: Not a bug
 [2013-08-30 20:51 UTC] aharvey@php.net
This is undefined behaviour in PHP, as in most languages with C-derived syntaxes, 
due to the lack of a sequence point between the post-increments.

Mailing list discussion from last month:
http://marc.info/?t=137427934300002&r=1&w=2

This is also documented, see example 1 on:
http://www.php.net/manual/en/language.operators.precedence.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 11 00:01:31 2024 UTC