------- Comment #3 from redi at gcc dot gnu dot org 2009-12-08 21:30 ------- (In reply to comment #2) > I am not sure this is such a good idea. A casting typically means "I want to > really do this". GCC normally suppress warnings when casting is added. A > warning when you assign when enum type to another and the first enum is not a > subset of the second could still be useful, but the casting should prevent the > warning.
That won't even compile without a cast, in C++ there is no implicit conversion to enumeration types. > I am not sure what happens for such assignment, is it undefined behaviour? If the source value is within the range of the target enum it's well-defined. It might be reasonable to warn as part of -Wconversion except that usually applies to implicit conversions, and for enums the implicit conversion isn't allowed. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30357