bug-bash
[Top][All Lists]
Advanced

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

Re: Arithmetic assignment side-effects


From: DJ Mills
Subject: Re: Arithmetic assignment side-effects
Date: Mon, 5 Aug 2013 22:57:20 -0400

On Sun, Aug 4, 2013 at 4:41 PM, Andreas Schwab <schwab@linux-m68k.org>wrote:

> Chris Down <chris@chrisdown.name> writes:
>
> 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.
>
>
I still don't see that; for one thing even with:

#include <stdio.h>

int main(void) {
  int x = 0;
  printf("%d\n", x = x + (x = 1));

  return 0;
}

I'm still seeing "assign x = 1, then do x + x, then assign the result to
x", which would give 2. gcc agrees with me. Especially with the parens
there, that's the order I would expect, but it's the same without as well.


reply via email to

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