Updating the question Why this two rvalue references examples have different behavior?:
Source code:
int a = 0;
auto && b = a++;
++a;
cout << a << b << endl;
prints 20
Is it undefined behavior (UB) to use b
after the a++
call? Maybe we cannot use b
because it refers to a temporary?