0

Possible Duplicate:
Undefined Behavior and Sequence Points

What will the value of x in following line of code:- x = a++ + ++a + a++ actually compiler is giving x = 3..but how????

Community
  • 1
  • 1
Richa
  • 21
  • 1

2 Answers2

4

This is undefined behavior. Any answer is valid, up to and including crashing. It is unlikely that any particular answer will be consistent between platforms. Don't do this.

Thom Smith
  • 13,916
  • 6
  • 45
  • 91
0

Undefined behavior, as the value of a is modified multiple time in the same statement.

Macmade
  • 52,708
  • 13
  • 106
  • 123