Think of the values of unsigned int
being drawn on a large clock face with the largest possible value (UINT_MAX) being next to zero.
Subtracting 3 from 1 moves you 3 places back on the clock (which gives you UINT_MAX - 1), and adding 5 to this moves you 5 places forward.
The net effect is to add 2 to 1, but it's important to know that the intermediate value is perfectly well defined by the C++ standard. It is not garbage, but related to the value of UINT_MAX
on your platform.
Note that the well-defined nature of this overflow is not true for signed
types. The behaviour on overflowing a signed
type is undefined in C++.