A Position class is a class with x,y variables. I'm getting bad values of y when I try to add them together. If someone could point out a mistake, that would help :)
Position first(1,1);
Position second(2,3);
(first + second).print(); // Prints garbage for y
Position third(first + second);
third.print(); // prints the correct value
In the original you were returning a reference to the return value from operator+=, and that return value was a reference. The compiler can't, without analyzing operator+=, assume that operator += returns a reference to the same object it was invoked on, so it doesn't warn you. Depending on the implementation of operator+=, it could be perfectly safe to do.
In the second, the compiler can clearly see you're returning a reference to a local object.