Re: Whacky increment/assignment logic with $foo++ vs ++$foo

From: Date: Sun, 04 Oct 2009 01:06:23 +0000
Subject: Re: Whacky increment/assignment logic with $foo++ vs ++$foo
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-298542@lists.php.net to get a copy of this message
Ben Dunlap wrote:
... and, in fact, that /is/ how C behaves. The following code:
No, that's implementation's behaviour. AFAIK, the normative document give to compiler the behaviour implementation. So, it can do optimization, that gives strange behaviour for a people how think increment operators had a wall defined behaviour.
int a = 2; a = a++; printf("a = [%d]\n", a); Will output "a = [3]". At least on Ubuntu 9 using gcc 4.3.3.
That's gcc way :) -- Mickaël Wolff aka Lupus Michaelis http://lupusmic.org

« previous php.general (#298542) next »