This has just bit me, so i though it would be nice to avoid that next time :)
Motivational case:
https://godbolt.org/g/cq9UNk
Basically, it's likely to happen if you don't like shadowing issues,
and use -Wshadow and friends. And it won't be diagnosed by clang.
The reason is, these self-assign diagnostics only work for builtin assignment
operators. Which makes sense, one could have a very special operator=,
that does something unusual in case of self-assignment,
so it may make sense to not warn on that.
But while it may be intentional in some cases, it may be a bug in other cases,
so it would be really great to have some diagnostic about it...
I understand why x &= x and x |= x are mathematically special for the built-in types, but surely x -= x and x ^= x and x /= x are just as likely to indicate programmer error. I would be happy if Clang either took the philosophical stance "We will diagnose x = x but uniformly never x op= x," or else took the pragmatic stance "We will diagnose any x op= x or x op x that seems likely to be a programming bug." This "middle way" of warning only for &= and |= is bothersome to me.