… or a value computation using the value of the same scalar object …
The important part is bolded here. The left hand side does not use the value of i
for the value computation. What is being computed is a glvalue. Only afterwards (sequenced after), the value of the object is touched and replaced.
Unfortunately this is a very subtle point 🙂
More Related Contents:
- Has C++ standard changed with respect to the use of indeterminate values and undefined behavior in C++14?
- Optimizing away a “while(1);” in C++0x
- In C++11, does `i += ++i + 1` exhibit undefined behavior?
- In which versions of the C++ standard does “(i+=10)+=10” have undefined behaviour?
- Accessing inactive union member and undefined behavior?
- Does initialization entail lvalue-to-rvalue conversion? Is `int x = x;` UB?
- Do I need to cast to unsigned char before calling toupper(), tolower(), et al.?
- Why does left shift operation invoke Undefined Behaviour when the left side operand has negative value?
- Why do constant expressions have an exclusion for undefined behavior?
- Where exactly does C++ standard say dereferencing an uninitialized pointer is undefined behavior?
- Is the size of std::array defined by standard
- Capturing a reference by reference in a C++11 lambda
- Is this infinite recursion UB?
- Does not evaluating the expression to which sizeof is applied make it legal to dereference a null or invalid pointer inside sizeof in C++?
- Why is modifying a string through a retrieved pointer to its data not allowed?
- Is it legal to declare a constexpr initializer_list object?
- Are notes and examples in the core language specification of the C++ Standard non-normative?
- Can C++ code be valid in both C++03 and C++11 but do different things?
- What is the value category of the operands of C++ operators when unspecified?
- How can an incomplete type be used as a template parameter to vector here?
- Are pointer variables just integers with some operators or are they “symbolic”?
- Is left-shifting (
- The behaviour of floating point division by zero
- What is the purpose of a declaration like int (x); or int (x) = 10;
- Can branches with undefined behavior be assumed unreachable and optimized as dead code?
- Is writing to &str[0] buffer (of a std:string) well-defined behaviour in C++11?
- Does C++11 allow dollar signs in identifiers?
- reinterpret_cast between char* and std::uint8_t* – safe?
- Does C++11 change the behavior of explicitly calling std::swap to ensure ADL-located swap’s are found, like boost::swap?
- C++11 cross compiler/standard library random distribution reproducibility