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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: xiezhenye at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Fri Mar 14 15:01:30 2025 UTC