-1

as title, in C++, is the evaluation order defined for

a[i++] = i;

?

athos
  • 5,550
  • 3
  • 40
  • 81

1 Answers1

2

No. You cannot use a single variable more than once in a full expression if at any point it's changed.

dascandy
  • 6,916
  • 1
  • 25
  • 49
  • 1
    Not totally true, you have to take into account [sequence points](http://stackoverflow.com/questions/3575350/sequence-points-in-c), but in this case, yes, it's undefined behavior – Garf365 Feb 03 '17 at 09:33
  • This will change shortly [with C++17](http://stackoverflow.com/questions/38501587/what-are-the-evaluation-order-guarantees-introduced-by-c17) though. – Quentin Feb 03 '17 at 09:51
  • Please extend your answer concerning C++17 features. – DawidPi Feb 16 '17 at 14:20
  • 1
    @DawidPi I cannot add anything that would not be in Quentin's linked question already in a better format. – dascandy Feb 17 '17 at 07:24