After stumbling across the question "Why are these constructs using pre and post-increment undefined behavior?" today I decided to grab the newest draft for the next C standard I could find and read more about it.
Shortly after I discovered the following paragraph in a C17 draft:
An expression is a sequence of operators and operands that specifies computation of a value, or that designates an object or a function, or that generates side effects, or that performs a combination thereof. The value computations of the operands of an operator are sequenced before the value computation of the result of the operator
Source: ISO/IEC 9899:2017, Section 6.5 §1 "Expressions" (link broken use web.archive.org)
Now I am a little confused. Doesn't that mean that i = i++
is defined behavior? I looked at another draft, C99 this time:
An expression is a sequence of operators and operands that specifies computation of a value, or that designates an object or a function, or that generates side effects, or that performs a combination thereof.
Source: ISO/IEC 9899:1999, Section 6.5 §1 "Expressions"
It's missing that very sentence!
Questions
- Did I misunderstand something?
- Are the answers outdated?
- Did I look at the wrong draft?
Note: this question is related, it's about C++ though.