[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arithmetic assignment side-effects

From: Andreas Schwab
Subject: Re: Arithmetic assignment side-effects
Date: Sun, 04 Aug 2013 22:41:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Chris Down <address@hidden> writes:

> On 2013-08-03 17:04, Dan Douglas wrote:
>> Is it specified what the value of x should be after this expression?
>> x=0; : $((x+=x=1))
> I don't know if it is specified in a standard (I suspect it may be undefined),
> but it looks pretty clear to me that the answer should be 2. Has anyone 
> proposed
> logic that would suggest it should be 1?

x+=a is the same as x=x+a.  Now replace a by (x=1) and it becomes
obvious that 1 is a perfectly valid outcome.


Andreas Schwab, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]