I've recently encountered a piece of code that supposedly works fine, but I don't quite understand why.

```cpp
size_t a = 19;
std::cout<<std::bitset<8>(a)<<std::endl;
a ^= a & -a;
std::cout<<std::bitset<8>(a)<<std::endl;

```

This piece of code will invert the least significant bit of a given unsigned integer. I would prefer to just write `a ^= 1;`, but I'm puzzled by why the piece of code above actually works. I would think that making an `unsigned int` negative will result in undefined behavior?