0

While reading MISRA CPP 2008, I have stumbled upon the following example:

x = b[i] + i++;

this example shows that order of evaluation can affect result, and there is undefined behavior due to 2 ways are possible:

  • 1.b[i] then i++
  • 2.i++ then b[i]

as far as I remember from CS courses - i will be incremented only after the whole expression evaluation, is that true?
If so could you please provide me with the reference to relevant info in the standard?

spin_eight
  • 3,925
  • 10
  • 39
  • 61

0 Answers0