Undefined rules of behavior for i = ++ i, etc.

I combed my rules of behavior undefined and read the following:

Undefined behavior and sequence points
Why is the behavior of f (i = -1, i = -1) undefined?
Why is `x--> 0` not undefined, but is` x = x -`?

And in C ++ 11, the behavior of `i + = ++ i + 1` demonstrates undefined behavior?

And it ended with three questions:

  • Are undefined behaviors used for form terms i=i++for non-target types? (The expression must be translated to i.operator(i.operator++(i)), and since every function call is a sequence point, it must be well defined if I understand the standard correctly)
  • Why is f(i=-1, i=-1)undefined behavior combined with "The result of the assignment operation is the value stored in the left operand after the assignment is executed, the result is the value lvalue" (ref) [ / questions / 466 / undefined-behavior-and-sequence-points / 7846 # 7846 ? (I understand that after this value I will be undefined, but the functioncall should be evaluated as f(-1, -1)if I understand the standard correctly.
  • What types of expressions became safe with C ++ 11/14 / 1z, only preincrement / predecrement in a simple assignment (no op=)?
+4
source share
1 answer

Forget about f (i = -1, i = -1). Suppose you have two pointers int* pand int* q, and you call

f (*p = 1, *q = 2)

undefined, p == q. , undefined, p == q? ( , , undefined, - ). , , , 99.999% , - ?

f (*p = -1, *q = -1)

. , , , ?

+2

All Articles