php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71010 Result of the program is not correct while the variable assignment by reference
Submitted: 2015-12-01 15:59 UTC Modified: 2015-12-05 15:38 UTC
From: miaojuanfeng at qq dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.6Git-2015-12-01 (Git) OS: linux
Private report: No CVE-ID: None
 [2015-12-01 15:59 UTC] miaojuanfeng at qq dot com
Description:
------------
Hi, I'm chinese, I do my best to let each other understand. :)

result of the program is not correct while the variable assignment by reference.

I have fixed the bug and pull request at github.

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

Expected result:
----------------
9

Actual result:
--------------
10

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-01 21:20 UTC] requinix@php.net
-Status: Open +Status: Verified
 [2015-12-01 21:20 UTC] requinix@php.net
Fixed in PHP 7. https://3v4l.org/GnfFs

Where is your pull request?
 [2015-12-02 07:13 UTC] miaojuanfeng at qq dot com
I have pull two request at github:

Fixed bug #71010 :part 1
Fixed bug #71010 :part 2

something failed. Hm...may be I don't know how to use github. 

I believe my code is correct.
 [2015-12-05 15:38 UTC] laruence@php.net
-Status: Verified +Status: Not a bug
 [2015-12-05 15:38 UTC] laruence@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

this is an undefined behavior, as in php the sequence point definition is similar as C.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 12:01:30 2024 UTC