I found this article: https://en.cppreference.com/w/cpp/language/eval_order
I have no idea why i = ++i;
and i = ++i + 2;
are undefined behavior.
First example:
int i = 5;
i = ++i;
The result will be still 6.
If i = ++i;
is stated as undefined behavior, then i = ++j;
should be stated as undefined behavior too (Because assignment can happen before increment?).
Second example:
int i = 5;
i = ++i + 2;
The result will be still 8.
If i = ++i + 2;
is stated as undefined behavior, then i = ++j + 2;
should be stated as undefined behavior too (because assignment can happen before increment and sum)?