From:             lew at mailduct dot com
Operating system: FreeBSD 4.8-REL
PHP version:      4.3.3
PHP Bug Type:     Math related
Bug description:  increment/decrement inconsistency and error

Description:
------------
There is a gross inconsistency between how the increment and decrement
operators function.  If you increment an empty variable, the operations
works correctly.  However, if you *decrement* an empty variable, the
operation leaves it unchanged!  See for yourself, with my clear example...

Reproduce code:
---------------
<?php

//  Increment some blank/empty variables...
$pos++; $pos++; $pos++;
$neg--; $neg--; $neg--;
//  Show them to us now...
print( "pos = $pos\n" );
print( "neg = $neg\n" );

//  Now do it another way (forced typecast)...
$ppp += 1; $ppp += 1; $ppp += 1;
$nnn -= 1; $nnn -= 1; $nnn -= 1;
//  Show them to us now...
print( "ppp = $ppp\n" );
print( "nnn = $nnn\n" );

#
#  Expected:
#    pos = 3    ppp = 3
#    neg = -3   nnn = -3
#
#  Actual:
#    pos = 3    ppp = 3
#    neg =      nnn = -3
?>


Expected result:
----------------
#
#  Expected:
#    pos = 3    ppp = 3
#    neg = -3   nnn = -3


Actual result:
--------------
#
#  Actual:
#    pos = 3    ppp = 3
#    neg =      nnn = -3

(note that $neg-- fails!)

-- 
Edit bug report at http://bugs.php.net/?id=25674&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25674&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25674&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=25674&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=25674&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=25674&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=25674&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=25674&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=25674&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=25674&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=25674&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=25674&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25674&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=25674&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=25674&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=25674&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25674&r=float

Reply via email to