Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Identify undefined behavior

...

The call to func() in this noncompliant code example has undefined behavior 34 because there is no sequence point between the argument expressions:

...

The first (left) argument expression reads the value of i (to determine the value to be stored) and then modifies i. The second (right) argument expression reads the value of i between the same pair of sequence points as the first argument, but not to determine the value to be stored in i. This additional attempt to read the value of i has undefined has undefined behavior 34.

Compliant Solution

This compliant solution is appropriate when the programmer intends for both arguments to func() to be equivalent:

...