https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118029
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- For extra fun: enum E { E0, E1, E2 }; E operator|(E lhs, E rhs) { return E(int(lhs) | int(rhs)); } void f(E e) { e |= E1|E2; } e2.cc: In function 'void f(E)': e2.cc:6:11: error: invalid conversion from 'int' to 'E' [-fpermissive] 6 | e |= E1|E2; | ^~ | | | int Now this seems really bad. If the user understands that a |= b works like a = a|b then it's really confusing where the int comes from, because a|b isn't an int. So they have to know that it's a bit like a=a|b but not really. Again, EDG is great: "e2.cc", line 6: error: this operation on an enumerated type requires an applicable user-defined operator function e |= E1|E2; ^ 1 error detected in the compilation of "e2.cc". This clearly states that the built-in |= will never work, it doesn't matter what the type of the right operand is. EDG gives this diagnostic for all compound assignments that don't have a user-defined overload. G++ only seems to be confusing for the bitwise compound assignments &= and |= and ^= For += on enums G++ is less confusing (although still not as user-friendly as EDG): e2.cc:6:5: error: no match for 'operator+=' (operand types are 'E' and 'E') 6 | e += E1|E2; | ~~^~~~~~~~