This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR 12242 g++ should warn about out-of-range int->enum conversions
Manuel López-Ibáñez wrote:
We do but we warn, so would you rather get two warnings?
I think it would be good to have your new warning for things like:
enum X { A };
X x;
x = 10;
The "invalid conversion" warning is useful, but that just tells the user
"this program isn't ISO C++, but I'm compiling it anyhow". Your new
warning says "and the answer probably isn't going to be what you
expect". Especially since some early C++ compilers would have made "X"
be an "int" (as in C), legacy code compiled with -fpermissive might have
problems like this.
So, I think it would be better if you could put your check into the
generic conversion code. Presumably, it could be done at the point that
the compiler actually converts "10" to "X".
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713